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_or_free (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_or_free
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
));
1558 /* 16M entries ought to be plenty. */
1559 bfd_set_error (bfd_error_bad_value
);
1560 _bfd_error_handler (_("dst_define_location %u too large"), loc
);
1564 /* Grow the ptr offset table if necessary. */
1565 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1567 PRIV (dst_ptr_offsets
)
1568 = bfd_realloc_or_free (PRIV (dst_ptr_offsets
),
1569 (loc
+ 1) * sizeof (unsigned int));
1570 if (PRIV (dst_ptr_offsets
) == NULL
)
1572 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1575 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1579 /* Restore saved DST location counter from specified index. */
1582 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1584 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1586 if (loc
< PRIV (dst_ptr_offsets_count
))
1588 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1594 /* Retrieve saved DST location counter from specified index. */
1597 dst_retrieve_location (bfd
*abfd
, bfd_vma
*loc
)
1599 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int) *loc
));
1601 if (*loc
< PRIV (dst_ptr_offsets_count
))
1603 *loc
= PRIV (dst_ptr_offsets
)[*loc
];
1609 /* Write multiple bytes to section image. */
1612 image_write (bfd
*abfd
, unsigned char *ptr
, unsigned int size
)
1614 asection
*sec
= PRIV (image_section
);
1615 size_t off
= PRIV (image_offset
);
1619 || size
> sec
->size
- off
)
1621 bfd_set_error (bfd_error_bad_value
);
1626 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1630 if (PRIV (image_section
)->contents
!= NULL
)
1631 memcpy (sec
->contents
+ off
, ptr
, size
);
1635 for (i
= 0; i
< size
; i
++)
1638 bfd_set_error (bfd_error_bad_value
);
1644 _bfd_hexdump (9, ptr
, size
, 0);
1647 PRIV (image_offset
) += size
;
1651 /* Write byte to section image. */
1654 image_write_b (bfd
* abfd
, unsigned int value
)
1656 unsigned char data
[1];
1658 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1662 return image_write (abfd
, data
, sizeof (data
));
1665 /* Write 2-byte word to image. */
1668 image_write_w (bfd
* abfd
, unsigned int value
)
1670 unsigned char data
[2];
1672 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1674 bfd_putl16 (value
, data
);
1675 return image_write (abfd
, data
, sizeof (data
));
1678 /* Write 4-byte long to image. */
1681 image_write_l (bfd
* abfd
, unsigned long value
)
1683 unsigned char data
[4];
1685 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1687 bfd_putl32 (value
, data
);
1688 return image_write (abfd
, data
, sizeof (data
));
1691 /* Write 8-byte quad to image. */
1694 image_write_q (bfd
* abfd
, bfd_vma value
)
1696 unsigned char data
[8];
1698 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1700 bfd_putl64 (value
, data
);
1701 return image_write (abfd
, data
, sizeof (data
));
1705 _bfd_vms_etir_name (int cmd
)
1709 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1710 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1711 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1712 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1713 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1714 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1715 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1716 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1717 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1718 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1719 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1720 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1721 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1722 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1723 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1724 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1725 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1726 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1727 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1728 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1729 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1730 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1731 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1732 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1733 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1734 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1735 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1736 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1737 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1738 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1739 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1740 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1741 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1742 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1743 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1744 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1745 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1746 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1747 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1748 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1749 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1750 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1751 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1752 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1753 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1754 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1755 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1756 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1757 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1760 /* These names have not yet been added to this switch statement. */
1761 _bfd_error_handler (_("unknown ETIR command %d"), cmd
);
1766 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1769 _bfd_vms_get_value (bfd
*abfd
,
1770 const unsigned char *ascic
,
1771 const unsigned char *max_ascic
,
1772 struct bfd_link_info
*info
,
1774 struct alpha_vms_link_hash_entry
**hp
)
1779 struct alpha_vms_link_hash_entry
*h
;
1781 /* Not linking. Do not try to resolve the symbol. */
1790 if (ascic
+ len
>= max_ascic
)
1792 _bfd_error_handler (_("corrupt vms value"));
1798 for (i
= 0; i
< len
; i
++)
1799 name
[i
] = ascic
[i
+ 1];
1802 h
= (struct alpha_vms_link_hash_entry
*)
1803 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1808 && (h
->root
.type
== bfd_link_hash_defined
1809 || h
->root
.type
== bfd_link_hash_defweak
))
1810 *vma
= h
->root
.u
.def
.value
1811 + h
->root
.u
.def
.section
->output_offset
1812 + h
->root
.u
.def
.section
->output_section
->vma
;
1813 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1817 (*info
->callbacks
->undefined_symbol
)
1818 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
);
1825 #define RELC_SHR_BASE 0x10000
1826 #define RELC_SEC_BASE 0x20000
1827 #define RELC_MASK 0x0ffff
1830 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1832 /* Handle undefined symbols. */
1833 if (h
== NULL
|| h
->sym
== NULL
)
1836 if (h
->sym
->typ
== EGSD__C_SYMG
)
1838 if (h
->sym
->flags
& EGSY__V_REL
)
1839 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1842 /* Can this happen (non-relocatable symg) ? I'd like to see
1847 if (h
->sym
->typ
== EGSD__C_SYM
)
1849 if (h
->sym
->flags
& EGSY__V_REL
)
1858 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1860 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1864 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1865 unsigned int rel
, bfd_vma vma
)
1869 if (PRIV (sections
) == NULL
)
1872 sec
= PRIV (sections
)[rel
& RELC_MASK
];
1876 if (sec
->output_section
== NULL
)
1878 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1881 return vma
+ sec
->vma
;
1884 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1885 the output section (used during linking).
1886 Return FALSE in case of error. */
1889 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1892 unsigned int length
;
1893 unsigned char *maxptr
;
1896 unsigned int rel1
= RELC_NONE
;
1897 unsigned int rel2
= RELC_NONE
;
1898 struct alpha_vms_link_hash_entry
*h
;
1900 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1901 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1903 ptr
= PRIV (recrd
.rec
);
1904 length
= PRIV (recrd
.rec_size
);
1905 maxptr
= ptr
+ length
;
1907 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1909 while (ptr
< maxptr
)
1911 int cmd
, cmd_length
;
1913 if (ptr
+ 4 > maxptr
)
1916 cmd
= bfd_getl16 (ptr
);
1917 cmd_length
= bfd_getl16 (ptr
+ 2);
1919 /* PR 21589 and 21579: Check for a corrupt ETIR record. */
1920 if (cmd_length
< 4 || ptr
+ cmd_length
> maxptr
)
1923 _bfd_error_handler (_("corrupt ETIR record encountered"));
1924 bfd_set_error (bfd_error_bad_value
);
1930 _bfd_vms_debug (4, "etir: %s(%d)\n",
1931 _bfd_vms_etir_name (cmd
), cmd
);
1932 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1940 stack 32 bit value of symbol (high bits set to 0). */
1941 case ETIR__C_STA_GBL
:
1942 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
1943 if (!_bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
)))
1950 stack 32 bit value, sign extend to 64 bit. */
1951 case ETIR__C_STA_LW
:
1952 if (ptr
+ 4 > maxptr
)
1954 if (!_bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
))
1961 stack 64 bit value of symbol. */
1962 case ETIR__C_STA_QW
:
1963 if (ptr
+ 8 > maxptr
)
1965 if (!_bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
))
1969 /* Stack psect base plus quadword offset
1970 arg: lw section index
1971 qw signed quadword offset (low 32 bits)
1973 Stack qw argument and section index
1974 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1975 case ETIR__C_STA_PQ
:
1979 if (ptr
+ 12 > maxptr
)
1981 psect
= bfd_getl32 (ptr
);
1982 if ((unsigned int) psect
>= PRIV (section_count
))
1984 _bfd_error_handler (_("bad section index in %s"),
1985 _bfd_vms_etir_name (cmd
));
1986 bfd_set_error (bfd_error_bad_value
);
1989 op1
= bfd_getl64 (ptr
+ 4);
1990 if (!_bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
))
1995 case ETIR__C_STA_LI
:
1996 case ETIR__C_STA_MOD
:
1997 case ETIR__C_STA_CKARG
:
1998 _bfd_error_handler (_("unsupported STA cmd %s"),
1999 _bfd_vms_etir_name (cmd
));
2003 /* Store byte: pop stack, write byte
2006 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2008 if (rel1
!= RELC_NONE
)
2010 if (!image_write_b (abfd
, (unsigned int) op1
& 0xff))
2014 /* Store word: pop stack, write word
2017 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2019 if (rel1
!= RELC_NONE
)
2021 if (!image_write_w (abfd
, (unsigned int) op1
& 0xffff))
2025 /* Store longword: pop stack, write longword
2027 case ETIR__C_STO_LW
:
2028 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2030 if (rel1
& RELC_SEC_BASE
)
2032 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2035 else if (rel1
& RELC_SHR_BASE
)
2037 if (!alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
))
2041 if (rel1
!= RELC_NONE
)
2043 if (rel1
!= RELC_REL
)
2045 if (!alpha_vms_add_lw_reloc (info
))
2048 if (!image_write_l (abfd
, op1
))
2052 /* Store quadword: pop stack, write quadword
2054 case ETIR__C_STO_QW
:
2055 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2057 if (rel1
& RELC_SEC_BASE
)
2059 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2062 else if (rel1
& RELC_SHR_BASE
)
2064 if (rel1
!= RELC_NONE
)
2066 if (rel1
!= RELC_REL
)
2068 if (!alpha_vms_add_qw_reloc (info
))
2071 if (!image_write_q (abfd
, op1
))
2075 /* Store immediate repeated: pop stack for repeat count
2078 case ETIR__C_STO_IMMR
:
2082 if (ptr
+ 4 > maxptr
)
2084 size
= bfd_getl32 (ptr
);
2085 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2087 if (rel1
!= RELC_NONE
)
2090 if (!image_write (abfd
, ptr
+ 4, size
))
2095 /* Store global: write symbol value
2096 arg: cs global symbol name. */
2097 case ETIR__C_STO_GBL
:
2098 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2101 if (h
->sym
->typ
== EGSD__C_SYMG
)
2103 if (!alpha_vms_add_fixup_qr (info
, abfd
, h
->sym
->owner
,
2104 h
->sym
->symbol_vector
))
2110 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
2112 if (!alpha_vms_add_qw_reloc (info
))
2116 if (!image_write_q (abfd
, op1
))
2120 /* Store code address: write address of entry point
2121 arg: cs global symbol name (procedure). */
2122 case ETIR__C_STO_CA
:
2123 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2126 if (h
->sym
->flags
& EGSY__V_NORM
)
2128 /* That's really a procedure. */
2129 if (h
->sym
->typ
== EGSD__C_SYMG
)
2131 if (!alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
))
2133 op1
= h
->sym
->symbol_vector
;
2137 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2138 h
->sym
->code_value
);
2139 if (!alpha_vms_add_qw_reloc (info
))
2145 /* Symbol is not a procedure. */
2149 if (!image_write_q (abfd
, op1
))
2153 /* Store offset to psect: pop stack, add low 32 bits to base of psect
2155 case ETIR__C_STO_OFF
:
2156 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2159 if (!(rel1
& RELC_SEC_BASE
))
2162 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2164 if (!image_write_q (abfd
, op1
))
2169 arg: lw count of bytes
2171 case ETIR__C_STO_IMM
:
2175 if (ptr
+ 4 > maxptr
)
2177 size
= bfd_getl32 (ptr
);
2178 if (!image_write (abfd
, ptr
+ 4, size
))
2183 /* This code is 'reserved to digital' according to the openVMS
2184 linker manual, however it is generated by the DEC C compiler
2185 and defined in the include file.
2186 FIXME, since the following is just a guess
2187 store global longword: store 32bit value of symbol
2188 arg: cs symbol name. */
2189 case ETIR__C_STO_GBL_LW
:
2190 _bfd_vms_get_value (abfd
, ptr
, maxptr
, info
, &op1
, &h
);
2194 if (!image_write_l (abfd
, op1
))
2198 case ETIR__C_STO_RB
:
2199 case ETIR__C_STO_AB
:
2200 case ETIR__C_STO_LP_PSB
:
2201 _bfd_error_handler (_("%s: not supported"),
2202 _bfd_vms_etir_name (cmd
));
2205 case ETIR__C_STO_HINT_GBL
:
2206 case ETIR__C_STO_HINT_PS
:
2207 _bfd_error_handler (_("%s: not implemented"),
2208 _bfd_vms_etir_name (cmd
));
2212 /* 200 Store-conditional Linkage Pair
2214 case ETIR__C_STC_LP
:
2216 /* 202 Store-conditional Address at global address
2220 case ETIR__C_STC_GBL
:
2222 /* 203 Store-conditional Code Address at global address
2224 cs procedure name. */
2225 case ETIR__C_STC_GCA
:
2227 /* 204 Store-conditional Address at psect + offset
2231 case ETIR__C_STC_PS
:
2232 _bfd_error_handler (_("%s: not supported"),
2233 _bfd_vms_etir_name (cmd
));
2237 /* 201 Store-conditional Linkage Pair with Procedure Signature
2243 case ETIR__C_STC_LP_PSB
:
2244 _bfd_vms_get_value (abfd
, ptr
+ 4, maxptr
, info
, &op1
, &h
);
2247 if (h
->sym
->typ
== EGSD__C_SYMG
)
2249 if (!alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
))
2251 op1
= h
->sym
->symbol_vector
;
2256 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2257 h
->sym
->code_value
);
2258 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2264 /* Undefined symbol. */
2268 if (!image_write_q (abfd
, op1
)
2269 || !image_write_q (abfd
, op2
))
2273 /* 205 Store-conditional NOP at address of global
2275 case ETIR__C_STC_NOP_GBL
:
2278 /* 207 Store-conditional BSR at global address
2281 case ETIR__C_STC_BSR_GBL
:
2284 /* 209 Store-conditional LDA at global address
2287 case ETIR__C_STC_LDA_GBL
:
2290 /* 211 Store-conditional BSR or Hint at global address
2293 case ETIR__C_STC_BOH_GBL
:
2294 /* Currentl ignored. */
2297 /* 213 Store-conditional NOP,BSR or HINT at global address
2300 case ETIR__C_STC_NBH_GBL
:
2302 /* 206 Store-conditional NOP at pect + offset
2305 case ETIR__C_STC_NOP_PS
:
2307 /* 208 Store-conditional BSR at pect + offset
2310 case ETIR__C_STC_BSR_PS
:
2312 /* 210 Store-conditional LDA at psect + offset
2315 case ETIR__C_STC_LDA_PS
:
2317 /* 212 Store-conditional BSR or Hint at pect + offset
2320 case ETIR__C_STC_BOH_PS
:
2322 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2324 case ETIR__C_STC_NBH_PS
:
2325 _bfd_error_handler (_("%s: not supported"),
2326 _bfd_vms_etir_name (cmd
));
2330 /* Det relocation base: pop stack, set image location counter
2332 case ETIR__C_CTL_SETRB
:
2333 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2335 if (!(rel1
& RELC_SEC_BASE
))
2337 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2340 /* Augment relocation base: increment image location counter by offset
2341 arg: lw offset value. */
2342 case ETIR__C_CTL_AUGRB
:
2343 if (ptr
+ 4 > maxptr
)
2345 op1
= bfd_getl32 (ptr
);
2346 image_inc_ptr (abfd
, op1
);
2349 /* Define location: pop index, save location counter under index
2351 case ETIR__C_CTL_DFLOC
:
2352 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2354 if (rel1
!= RELC_NONE
)
2356 if (!dst_define_location (abfd
, op1
))
2360 /* Set location: pop index, restore location counter from index
2362 case ETIR__C_CTL_STLOC
:
2363 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2365 if (rel1
!= RELC_NONE
)
2367 if (!dst_restore_location (abfd
, op1
))
2369 bfd_set_error (bfd_error_bad_value
);
2370 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STLOC");
2375 /* Stack defined location: pop index, push location counter from index
2377 case ETIR__C_CTL_STKDL
:
2378 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2380 if (rel1
!= RELC_NONE
)
2382 if (!dst_retrieve_location (abfd
, &op1
))
2384 bfd_set_error (bfd_error_bad_value
);
2385 _bfd_error_handler (_("invalid %s"), "ETIR__C_CTL_STKDL");
2388 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
))
2392 case ETIR__C_OPR_NOP
: /* No-op. */
2395 case ETIR__C_OPR_ADD
: /* Add. */
2396 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2397 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2399 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2401 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2403 if (!_bfd_vms_push (abfd
, op1
+ op2
, rel1
))
2407 case ETIR__C_OPR_SUB
: /* Subtract. */
2408 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2409 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2411 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2413 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2415 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2416 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2419 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2421 if (!_bfd_vms_push (abfd
, op2
- op1
, rel1
))
2425 case ETIR__C_OPR_MUL
: /* Multiply. */
2426 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2427 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2429 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2431 if (!_bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
))
2435 case ETIR__C_OPR_DIV
: /* Divide. */
2436 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2437 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2439 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2443 if (!_bfd_vms_push (abfd
, 0, RELC_NONE
))
2448 if (!_bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
))
2453 case ETIR__C_OPR_AND
: /* Logical AND. */
2454 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2455 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2457 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2459 if (!_bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
))
2463 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2464 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2465 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2467 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2469 if (!_bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
))
2473 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2474 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2475 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2477 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2479 if (!_bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
))
2483 case ETIR__C_OPR_NEG
: /* Negate. */
2484 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2486 if (rel1
!= RELC_NONE
)
2488 if (!_bfd_vms_push (abfd
, -op1
, RELC_NONE
))
2492 case ETIR__C_OPR_COM
: /* Complement. */
2493 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2495 if (rel1
!= RELC_NONE
)
2497 if (!_bfd_vms_push (abfd
, ~op1
, RELC_NONE
))
2501 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2502 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2503 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2505 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2508 _bfd_error_handler (_("invalid use of %s with contexts"),
2509 _bfd_vms_etir_name (cmd
));
2512 if ((int)op2
< 0) /* Shift right. */
2514 else /* Shift left. */
2516 if (!_bfd_vms_push (abfd
, op1
, RELC_NONE
)) /* FIXME: sym. */
2520 case ETIR__C_OPR_INSV
: /* Insert field. */
2521 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2522 case ETIR__C_OPR_ROT
: /* Rotate. */
2523 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2524 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2525 _bfd_error_handler (_("%s: not supported"),
2526 _bfd_vms_etir_name (cmd
));
2530 case ETIR__C_OPR_SEL
: /* Select. */
2531 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2535 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
))
2540 if (!_bfd_vms_pop (abfd
, &op1
, &rel1
)
2541 || !_bfd_vms_pop (abfd
, &op2
, &rel2
))
2543 if (!_bfd_vms_push (abfd
, op1
, rel1
))
2549 _bfd_error_handler (_("reserved cmd %d"), cmd
);
2554 ptr
+= cmd_length
- 4;
2560 /* Process EDBG/ETBT record.
2561 Return TRUE on success, FALSE on error */
2564 vms_slurp_debug (bfd
*abfd
)
2566 asection
*section
= PRIV (dst_section
);
2568 if (section
== NULL
)
2570 /* We have no way to find out beforehand how much debug info there
2571 is in an object file, so pick an initial amount and grow it as
2573 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2576 section
= bfd_make_section (abfd
, "$DST$");
2579 if (!bfd_set_section_flags (section
, flags
))
2581 PRIV (dst_section
) = section
;
2584 PRIV (image_section
) = section
;
2585 PRIV (image_offset
) = section
->size
;
2587 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2590 section
->size
= PRIV (image_offset
);
2594 /* Process EDBG record.
2595 Return TRUE on success, FALSE on error. */
2598 _bfd_vms_slurp_edbg (bfd
*abfd
)
2600 vms_debug2 ((2, "EDBG\n"));
2602 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2604 return vms_slurp_debug (abfd
);
2607 /* Process ETBT record.
2608 Return TRUE on success, FALSE on error. */
2611 _bfd_vms_slurp_etbt (bfd
*abfd
)
2613 vms_debug2 ((2, "ETBT\n"));
2615 abfd
->flags
|= HAS_LINENO
;
2617 return vms_slurp_debug (abfd
);
2620 /* Process EEOM record.
2621 Return TRUE on success, FALSE on error. */
2624 _bfd_vms_slurp_eeom (bfd
*abfd
)
2626 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2628 vms_debug2 ((2, "EEOM\n"));
2630 /* PR 21813: Check for an undersized record. */
2631 if (PRIV (recrd
.buf_size
) < sizeof (* eeom
))
2633 _bfd_error_handler (_("corrupt EEOM record - size is too small"));
2634 bfd_set_error (bfd_error_bad_value
);
2638 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2639 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2640 if (PRIV (eom_data
).eom_w_comcod
> 1)
2642 _bfd_error_handler (_("object module not error-free !"));
2643 bfd_set_error (bfd_error_bad_value
);
2647 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2648 if (PRIV (recrd
.rec_size
) > 10)
2650 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2651 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2652 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2653 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2655 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2660 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2663 _bfd_vms_slurp_object_records (bfd
* abfd
)
2670 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2672 type
= _bfd_vms_get_object_record (abfd
);
2675 vms_debug2 ((2, "next_record failed\n"));
2682 ok
= _bfd_vms_slurp_ehdr (abfd
);
2685 ok
= _bfd_vms_slurp_eeom (abfd
);
2688 ok
= _bfd_vms_slurp_egsd (abfd
);
2691 ok
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2694 ok
= _bfd_vms_slurp_edbg (abfd
);
2697 ok
= _bfd_vms_slurp_etbt (abfd
);
2704 vms_debug2 ((2, "slurp type %d failed\n", type
));
2708 while (type
!= EOBJ__C_EEOM
);
2713 /* Initialize private data */
2715 vms_initialize (bfd
* abfd
)
2719 amt
= sizeof (struct vms_private_data_struct
);
2720 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2721 if (abfd
->tdata
.any
== NULL
)
2724 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2726 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2727 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2728 if (PRIV (stack
) == NULL
)
2734 bfd_release (abfd
, abfd
->tdata
.any
);
2735 abfd
->tdata
.any
= NULL
;
2739 /* Free malloc'd memory. */
2742 alpha_vms_free_private (bfd
*abfd
)
2744 struct module
*module
;
2746 free (PRIV (recrd
.buf
));
2747 free (PRIV (sections
));
2749 free (PRIV (dst_ptr_offsets
));
2751 for (module
= PRIV (modules
); module
; module
= module
->next
)
2752 free (module
->file_table
);
2755 /* Check the format for a file being read.
2756 Return a (bfd_target *) if it's an object file or zero if not. */
2759 alpha_vms_object_p (bfd
*abfd
)
2761 void *tdata_save
= abfd
->tdata
.any
;
2762 unsigned int test_len
;
2765 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2767 /* Allocate alpha-vms specific data. */
2768 if (!vms_initialize (abfd
))
2770 abfd
->tdata
.any
= tdata_save
;
2774 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2777 /* The first challenge with VMS is to discover the kind of the file.
2779 Image files (executable or shared images) are stored as a raw
2780 stream of bytes (like on UNIX), but there is no magic number.
2782 Object files are written with RMS (record management service), ie
2783 each records are preceeded by its length (on a word - 2 bytes), and
2784 padded for word-alignment. That would be simple but when files
2785 are transfered to a UNIX filesystem (using ftp), records are lost.
2786 Only the raw content of the records are transfered. Fortunately,
2787 the Alpha Object file format also store the length of the record
2788 in the records. Is that clear ? */
2790 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2791 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2792 4 bytes minor id, 4 bytes length). */
2794 buf
= _bfd_malloc_and_read (abfd
, test_len
, test_len
);
2797 PRIV (recrd
.buf
) = buf
;
2798 PRIV (recrd
.buf_size
) = test_len
;
2799 PRIV (recrd
.rec
) = buf
;
2801 /* Is it an image? */
2802 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2803 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2805 unsigned int eisd_offset
, eihs_offset
;
2807 /* Extract the header size. */
2808 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2810 /* The header size is 0 for DSF files. */
2811 if (PRIV (recrd
.rec_size
) == 0)
2812 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2814 /* PR 21813: Check for a truncated record. */
2815 /* PR 17512: file: 7d7c57c2. */
2816 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2817 goto err_wrong_format
;
2819 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2822 free (PRIV (recrd
.buf
));
2823 PRIV (recrd
.buf
) = NULL
;
2824 buf
= _bfd_malloc_and_read (abfd
, PRIV (recrd
.rec_size
),
2825 PRIV (recrd
.rec_size
));
2829 PRIV (recrd
.buf
) = buf
;
2830 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2831 PRIV (recrd
.rec
) = buf
;
2833 vms_debug2 ((2, "file type is image\n"));
2835 if (!_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
))
2836 goto err_wrong_format
;
2838 if (!_bfd_vms_slurp_eisd (abfd
, eisd_offset
))
2839 goto err_wrong_format
;
2841 /* EIHS is optional. */
2842 if (eihs_offset
!= 0 && !_bfd_vms_slurp_eihs (abfd
, eihs_offset
))
2843 goto err_wrong_format
;
2849 /* Assume it's a module and adjust record pointer if necessary. */
2850 maybe_adjust_record_pointer_for_object (abfd
);
2852 /* But is it really a module? */
2853 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2854 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2856 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2857 goto err_wrong_format
;
2859 vms_debug2 ((2, "file type is module\n"));
2861 type
= bfd_getl16 (PRIV (recrd
.rec
));
2862 if (type
!= EOBJ__C_EMH
|| !_bfd_vms_slurp_ehdr (abfd
))
2863 goto err_wrong_format
;
2865 if (!_bfd_vms_slurp_object_records (abfd
))
2866 goto err_wrong_format
;
2869 goto err_wrong_format
;
2872 /* Set arch_info to alpha. */
2874 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2875 goto err_wrong_format
;
2877 return alpha_vms_free_private
;
2880 bfd_set_error (bfd_error_wrong_format
);
2883 alpha_vms_free_private (abfd
);
2884 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2885 bfd_release (abfd
, abfd
->tdata
.any
);
2886 abfd
->tdata
.any
= tdata_save
;
2892 /* Write an EMH/MHD record. */
2895 _bfd_vms_write_emh (bfd
*abfd
)
2897 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2899 _bfd_vms_output_alignment (recwr
, 2);
2902 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2903 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2904 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2905 _bfd_vms_output_long (recwr
, 0);
2906 _bfd_vms_output_long (recwr
, 0);
2907 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2909 /* Create module name from filename. */
2910 if (bfd_get_filename (abfd
) != 0)
2912 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2913 _bfd_vms_output_counted (recwr
, module
);
2917 _bfd_vms_output_counted (recwr
, "NONAME");
2919 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2920 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2921 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2922 _bfd_vms_output_end (abfd
, recwr
);
2925 /* Write an EMH/LMN record. */
2928 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2931 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2932 unsigned int ver
= BFD_VERSION
/ 10000;
2935 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2936 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2937 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2938 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2939 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2940 _bfd_vms_output_end (abfd
, recwr
);
2944 /* Write eom record for bfd abfd. Return FALSE on error. */
2947 _bfd_vms_write_eeom (bfd
*abfd
)
2949 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2951 vms_debug2 ((2, "vms_write_eeom\n"));
2953 _bfd_vms_output_alignment (recwr
, 2);
2955 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2956 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2957 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2958 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2960 if ((abfd
->flags
& EXEC_P
) == 0
2961 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2965 section
= bfd_get_section_by_name (abfd
, ".link");
2968 bfd_set_error (bfd_error_nonrepresentable_section
);
2971 _bfd_vms_output_short (recwr
, 0);
2972 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2973 _bfd_vms_output_long (recwr
,
2974 (unsigned long) bfd_get_start_address (abfd
));
2975 _bfd_vms_output_long (recwr
, 0);
2978 _bfd_vms_output_end (abfd
, recwr
);
2983 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2985 if (vec
->nbr_el
>= vec
->max_el
)
2987 if (vec
->max_el
== 0)
2990 vec
->els
= bfd_malloc (vec
->max_el
* elsz
);
2995 if (vec
->max_el
> -1u / 2)
2997 bfd_set_error (bfd_error_file_too_big
);
3001 if (_bfd_mul_overflow (vec
->max_el
, elsz
, &amt
))
3003 bfd_set_error (bfd_error_file_too_big
);
3006 vec
->els
= bfd_realloc_or_free (vec
->els
, amt
);
3009 if (vec
->els
== NULL
)
3011 return (char *) vec
->els
+ elsz
* vec
->nbr_el
++;
3014 /* Bump ABFD file position to next block. */
3017 alpha_vms_file_position_block (bfd
*abfd
)
3020 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
3021 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3024 /* Convert from internal structure SRC to external structure DST. */
3027 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
3028 struct vms_eisd
*dst
)
3030 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
3031 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
3032 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
3033 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
3035 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
3036 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
3037 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
3038 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
3039 dst
->pfc
= src
->u
.eisd
.pfc
;
3040 dst
->matchctl
= src
->u
.eisd
.matchctl
;
3041 dst
->type
= src
->u
.eisd
.type
;
3043 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
3045 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
3046 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
3047 src
->u
.gbl_eisd
.gblnam
[0] + 1);
3051 /* Append EISD to the list of extra eisd for ABFD. */
3054 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
3057 if (PRIV (gbl_eisd_head
) == NULL
)
3058 PRIV (gbl_eisd_head
) = eisd
;
3060 PRIV (gbl_eisd_tail
)->next
= eisd
;
3061 PRIV (gbl_eisd_tail
) = eisd
;
3064 /* Create an EISD for shared image SHRIMG.
3065 Return FALSE in case of error. */
3068 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
3070 struct vms_internal_eisd_map
*eisd
;
3073 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
3074 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
3080 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3084 /* Fill the fields. */
3085 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
3086 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
3087 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
3088 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
3089 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
3090 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
3091 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
3092 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
3093 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
3094 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
3096 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
3097 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
3098 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
3100 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
3102 /* Append it to the list. */
3103 alpha_vms_append_extra_eisd (abfd
, eisd
);
3108 /* Create an EISD for section SEC.
3109 Return FALSE in case of failure. */
3112 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
3114 struct vms_internal_eisd_map
*eisd
;
3116 /* Only for allocating section. */
3117 if (!(sec
->flags
& SEC_ALLOC
))
3120 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
3121 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
3124 vms_section_data (sec
)->eisd
= eisd
;
3126 /* Fill the fields. */
3127 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
3128 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
3129 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
3130 eisd
->u
.eisd
.secsize
=
3131 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
3132 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
3133 eisd
->u
.eisd
.flags
= 0;
3134 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
3135 eisd
->u
.eisd
.pfc
= 0; /* Default. */
3136 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
3137 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
3139 if (sec
->flags
& SEC_CODE
)
3140 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
3141 if (!(sec
->flags
& SEC_READONLY
))
3142 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3144 /* If relocations or fixup will be applied, make this isect writeable. */
3145 if (sec
->flags
& SEC_RELOC
)
3146 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
3148 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3150 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
3151 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
3153 if (sec
->flags
& SEC_LINKER_CREATED
)
3155 if (strcmp (sec
->name
, "$FIXUP$") == 0)
3156 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
3159 /* Append it to the list. */
3161 if (PRIV (eisd_head
) == NULL
)
3162 PRIV (eisd_head
) = eisd
;
3164 PRIV (eisd_tail
)->next
= eisd
;
3165 PRIV (eisd_tail
) = eisd
;
3170 /* Layout executable ABFD and write it to the disk.
3171 Return FALSE in case of failure. */
3174 alpha_vms_write_exec (bfd
*abfd
)
3176 struct vms_eihd eihd
;
3177 struct vms_eiha
*eiha
;
3178 struct vms_eihi
*eihi
;
3179 struct vms_eihs
*eihs
= NULL
;
3181 struct vms_internal_eisd_map
*first_eisd
;
3182 struct vms_internal_eisd_map
*eisd
;
3185 file_ptr gst_filepos
= 0;
3186 unsigned int lnkflags
= 0;
3188 /* Build the EIHD. */
3189 PRIV (file_pos
) = EIHD__C_LENGTH
;
3191 memset (&eihd
, 0, sizeof (eihd
));
3192 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
3194 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
3195 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
3197 bfd_putl32 (sizeof (eihd
), eihd
.size
);
3198 bfd_putl32 (0, eihd
.isdoff
);
3199 bfd_putl32 (0, eihd
.activoff
);
3200 bfd_putl32 (0, eihd
.symdbgoff
);
3201 bfd_putl32 (0, eihd
.imgidoff
);
3202 bfd_putl32 (0, eihd
.patchoff
);
3203 bfd_putl64 (0, eihd
.iafva
);
3204 bfd_putl32 (0, eihd
.version_array_off
);
3206 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
3207 bfd_putl32 (0, eihd
.subtype
);
3209 bfd_putl32 (0, eihd
.imgiocnt
);
3210 bfd_putl32 (-1, eihd
.privreqs
);
3211 bfd_putl32 (-1, eihd
.privreqs
+ 4);
3213 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3215 bfd_putl32 (0, eihd
.ident
);
3216 bfd_putl32 (0, eihd
.sysver
);
3219 bfd_putl32 (0, eihd
.symvect_size
);
3220 bfd_putl32 (16, eihd
.virt_mem_block_size
);
3221 bfd_putl32 (0, eihd
.ext_fixup_off
);
3222 bfd_putl32 (0, eihd
.noopt_psect_off
);
3223 bfd_putl32 (-1, eihd
.alias
);
3226 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3227 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3228 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3230 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3231 bfd_putl32 (0, eiha
->spare
);
3232 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3233 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3234 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3235 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3236 bfd_putl64 (0, eiha
->inishr
);
3239 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3240 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3241 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3243 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3244 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3249 /* Set module name. */
3250 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3251 len
= strlen (module
);
3252 if (len
> sizeof (eihi
->imgnam
) - 1)
3253 len
= sizeof (eihi
->imgnam
) - 1;
3254 eihi
->imgnam
[0] = len
;
3255 memcpy (eihi
->imgnam
+ 1, module
, len
);
3263 vms_get_time (&hi
, &lo
);
3264 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3265 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3268 eihi
->linkid
[0] = 0;
3269 eihi
->imgbid
[0] = 0;
3272 dst
= PRIV (dst_section
);
3273 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3274 if (dst
!= NULL
&& dst
->size
!= 0)
3276 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3277 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3278 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3280 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3281 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3282 bfd_putl32 (0, eihs
->dstvbn
);
3283 bfd_putl32 (0, eihs
->dstsize
);
3284 bfd_putl32 (0, eihs
->gstvbn
);
3285 bfd_putl32 (0, eihs
->gstsize
);
3286 bfd_putl32 (0, eihs
->dmtvbn
);
3287 bfd_putl32 (0, eihs
->dmtsize
);
3290 /* One EISD per section. */
3291 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3293 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3297 /* Merge section EIDS which extra ones. */
3298 if (PRIV (eisd_tail
))
3299 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3301 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3302 if (PRIV (gbl_eisd_tail
))
3303 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3305 first_eisd
= PRIV (eisd_head
);
3307 /* Add end of eisd. */
3310 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3313 eisd
->u
.eisd
.majorid
= 0;
3314 eisd
->u
.eisd
.minorid
= 0;
3315 eisd
->u
.eisd
.eisdsize
= 0;
3316 alpha_vms_append_extra_eisd (abfd
, eisd
);
3319 /* Place EISD in the file. */
3320 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3322 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3324 /* First block is a little bit special: there is a word at the end. */
3325 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3327 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3328 alpha_vms_file_position_block (abfd
);
3330 eisd
->file_pos
= PRIV (file_pos
);
3331 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3333 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3334 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3337 if (first_eisd
!= NULL
)
3339 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3340 /* Real size of end of eisd marker. */
3341 PRIV (file_pos
) += EISD__K_LENEND
;
3344 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3345 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3348 /* Place sections. */
3349 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3351 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3354 eisd
= vms_section_data (sec
)->eisd
;
3356 /* Align on a block. */
3357 alpha_vms_file_position_block (abfd
);
3358 sec
->filepos
= PRIV (file_pos
);
3361 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3363 PRIV (file_pos
) += sec
->size
;
3367 if (eihs
!= NULL
&& dst
!= NULL
)
3369 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3370 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3374 lnkflags
|= EIHD__M_DBGDMT
;
3375 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3376 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3378 if (PRIV (gsd_sym_count
) != 0)
3380 alpha_vms_file_position_block (abfd
);
3381 gst_filepos
= PRIV (file_pos
);
3382 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3383 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3387 /* Write EISD in hdr. */
3388 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3390 alpha_vms_swap_eisd_out
3391 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3393 /* Write first block. */
3394 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3395 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3398 /* Write remaining eisd. */
3401 unsigned char blk
[VMS_BLOCK_SIZE
];
3402 struct vms_internal_eisd_map
*next_eisd
;
3404 memset (blk
, 0xff, sizeof (blk
));
3405 while (eisd
!= NULL
)
3407 alpha_vms_swap_eisd_out
3409 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3411 next_eisd
= eisd
->next
;
3412 if (next_eisd
== NULL
3413 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3414 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3416 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3419 memset (blk
, 0xff, sizeof (blk
));
3425 /* Write sections. */
3426 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3428 unsigned char blk
[VMS_BLOCK_SIZE
];
3431 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3433 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3437 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3438 if (len
!= VMS_BLOCK_SIZE
)
3440 memset (blk
, 0, len
);
3441 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3447 if (gst_filepos
!= 0)
3449 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3452 _bfd_vms_write_emh (abfd
);
3453 _bfd_vms_write_lmn (abfd
, "GNU LD");
3455 /* PSC for the absolute section. */
3456 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3457 _bfd_vms_output_long (recwr
, 0);
3458 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3459 _bfd_vms_output_short (recwr
, 0);
3460 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3461 _bfd_vms_output_long (recwr
, 0);
3462 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3463 _bfd_vms_output_end_subrec (recwr
);
3464 _bfd_vms_output_end (abfd
, recwr
);
3466 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3468 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3474 _bfd_vms_output_alignment (recwr
, 8);
3475 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3476 _bfd_vms_output_long (recwr
, 0);
3478 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3479 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3480 _bfd_vms_output_short (recwr
, sym
->flags
);
3482 if (sym
->code_section
)
3483 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3486 BFD_ASSERT (sym
->code_value
== 0);
3489 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3490 _bfd_vms_output_quad
3491 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3492 _bfd_vms_output_quad (recwr
, ep
);
3493 _bfd_vms_output_quad (recwr
, val
);
3494 _bfd_vms_output_long (recwr
, 0);
3495 _bfd_vms_output_counted (recwr
, sym
->name
);
3496 _bfd_vms_output_end_subrec (recwr
);
3498 _bfd_vms_output_end (abfd
, recwr
);
3501 _bfd_vms_output_end (abfd
, recwr
);
3503 if (!_bfd_vms_write_eeom (abfd
))
3511 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3514 _bfd_vms_write_egsd (bfd
*abfd
)
3518 unsigned int symnum
;
3520 flagword new_flags
, old_flags
;
3521 int abs_section_index
= -1;
3522 unsigned int target_index
= 0;
3523 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3525 vms_debug2 ((2, "vms_write_egsd\n"));
3527 /* Egsd is quadword aligned. */
3528 _bfd_vms_output_alignment (recwr
, 8);
3530 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3531 _bfd_vms_output_long (recwr
, 0);
3533 /* Number sections. */
3534 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3536 if (section
->flags
& SEC_DEBUGGING
)
3538 if (!strcmp (section
->name
, ".vmsdebug"))
3540 section
->flags
|= SEC_DEBUGGING
;
3543 section
->target_index
= target_index
++;
3546 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3548 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3549 section
->target_index
, section
->name
, (int)section
->size
));
3551 /* Don't write out the VMS debug info section since it is in the
3552 ETBT and EDBG sections in etir. */
3553 if (section
->flags
& SEC_DEBUGGING
)
3556 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3557 if (_bfd_vms_output_check (recwr
, 64) < 0)
3559 _bfd_vms_output_end (abfd
, recwr
);
3560 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3561 _bfd_vms_output_long (recwr
, 0);
3564 /* Don't know if this is necessary for the linker but for now it keeps
3565 vms_slurp_gsd happy. */
3566 sname
= section
->name
;
3569 /* Remove leading dot. */
3571 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3572 sname
= EVAX_CODE_NAME
;
3573 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3574 sname
= EVAX_DATA_NAME
;
3575 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3576 sname
= EVAX_BSS_NAME
;
3577 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3578 sname
= EVAX_LINK_NAME
;
3579 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3580 sname
= EVAX_READONLY_NAME
;
3581 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3582 sname
= EVAX_LITERAL_NAME
;
3583 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3584 sname
= EVAX_LITERALS_NAME
;
3585 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3586 sname
= EVAX_COMMON_NAME
;
3587 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3588 sname
= EVAX_LOCAL_NAME
;
3591 if (bfd_is_com_section (section
))
3592 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3593 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3595 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3598 /* Modify them as directed. */
3599 if (section
->flags
& SEC_READONLY
)
3600 new_flags
&= ~EGPS__V_WRT
;
3602 new_flags
&= ~vms_section_data (section
)->no_flags
;
3603 new_flags
|= vms_section_data (section
)->flags
;
3605 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3606 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3607 new_flags
, (unsigned long)section
->size
));
3609 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3610 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3611 _bfd_vms_output_short (recwr
, new_flags
);
3612 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3613 _bfd_vms_output_counted (recwr
, sname
);
3614 _bfd_vms_output_end_subrec (recwr
);
3616 /* If the section is an obsolute one, remind its index as it will be
3617 used later for absolute symbols. */
3618 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3619 abs_section_index
= section
->target_index
;
3622 /* Output symbols. */
3623 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3625 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3627 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3629 symbol
= abfd
->outsymbols
[symnum
];
3630 old_flags
= symbol
->flags
;
3632 /* Work-around a missing feature: consider __main as the main entry
3634 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3635 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3637 /* Only put in the GSD the global and the undefined symbols. */
3638 if (old_flags
& BSF_FILE
)
3641 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3643 /* If the LIB$INITIIALIZE section is present, add a reference to
3644 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3645 in the assembly file. */
3646 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3647 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3651 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3652 bytes for a possible ABS section. */
3653 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3655 _bfd_vms_output_end (abfd
, recwr
);
3656 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3657 _bfd_vms_output_long (recwr
, 0);
3660 if ((old_flags
& BSF_GLOBAL
) != 0
3661 && bfd_is_abs_section (symbol
->section
)
3662 && abs_section_index
<= 0)
3664 /* Create an absolute section if none was defined. It is highly
3665 unlikely that the name $ABS$ clashes with a user defined
3666 non-absolute section name. */
3667 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3668 _bfd_vms_output_short (recwr
, 4);
3669 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3670 _bfd_vms_output_long (recwr
, 0);
3671 _bfd_vms_output_counted (recwr
, "$ABS$");
3672 _bfd_vms_output_end_subrec (recwr
);
3674 abs_section_index
= target_index
++;
3677 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3679 /* Data type, alignment. */
3680 _bfd_vms_output_short (recwr
, 0);
3684 if (old_flags
& BSF_WEAK
)
3685 new_flags
|= EGSY__V_WEAK
;
3686 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3687 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3689 if (old_flags
& BSF_FUNCTION
)
3691 new_flags
|= EGSY__V_NORM
;
3692 new_flags
|= EGSY__V_REL
;
3694 if (old_flags
& BSF_GLOBAL
)
3696 new_flags
|= EGSY__V_DEF
;
3697 if (!bfd_is_abs_section (symbol
->section
))
3698 new_flags
|= EGSY__V_REL
;
3700 _bfd_vms_output_short (recwr
, new_flags
);
3702 if (old_flags
& BSF_GLOBAL
)
3704 /* Symbol definition. */
3705 bfd_vma code_address
= 0;
3706 unsigned long ca_psindx
= 0;
3707 unsigned long psindx
;
3709 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3714 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3715 code_address
= sym
->value
;
3716 ca_psindx
= sym
->section
->target_index
;
3718 if (bfd_is_abs_section (symbol
->section
))
3719 psindx
= abs_section_index
;
3721 psindx
= symbol
->section
->target_index
;
3723 _bfd_vms_output_quad (recwr
, symbol
->value
);
3724 _bfd_vms_output_quad (recwr
, code_address
);
3725 _bfd_vms_output_long (recwr
, ca_psindx
);
3726 _bfd_vms_output_long (recwr
, psindx
);
3728 _bfd_vms_output_counted (recwr
, symbol
->name
);
3730 _bfd_vms_output_end_subrec (recwr
);
3733 _bfd_vms_output_alignment (recwr
, 8);
3734 _bfd_vms_output_end (abfd
, recwr
);
3739 /* Write object header for bfd abfd. Return FALSE on error. */
3742 _bfd_vms_write_ehdr (bfd
*abfd
)
3745 unsigned int symnum
;
3746 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3748 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3750 _bfd_vms_output_alignment (recwr
, 2);
3752 _bfd_vms_write_emh (abfd
);
3753 _bfd_vms_write_lmn (abfd
, "GNU AS");
3756 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3757 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3759 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3761 symbol
= abfd
->outsymbols
[symnum
];
3763 if (symbol
->flags
& BSF_FILE
)
3765 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3766 (int) strlen (symbol
->name
));
3771 if (symnum
== abfd
->symcount
)
3772 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3774 _bfd_vms_output_end (abfd
, recwr
);
3777 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3778 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3779 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3780 _bfd_vms_output_end (abfd
, recwr
);
3783 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3784 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3785 _bfd_vms_output_dump (recwr
,
3786 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3788 _bfd_vms_output_end (abfd
, recwr
);
3793 /* Part 4.6, relocations. */
3796 /* WRITE ETIR SECTION
3798 This is still under construction and therefore not documented. */
3800 /* Close the etir/etbt record. */
3803 end_etir_record (bfd
* abfd
)
3805 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3807 _bfd_vms_output_end (abfd
, recwr
);
3811 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3813 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3815 if (section
->flags
& SEC_DEBUGGING
)
3817 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3821 /* Push start offset. */
3822 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3823 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3824 _bfd_vms_output_end_subrec (recwr
);
3827 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3828 _bfd_vms_output_end_subrec (recwr
);
3833 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3837 /* Push start offset. */
3838 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3839 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3840 _bfd_vms_output_quad (recwr
, offset
);
3841 _bfd_vms_output_end_subrec (recwr
);
3843 /* Start = pop (). */
3844 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3845 _bfd_vms_output_end_subrec (recwr
);
3850 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3851 address VADDR in section specified by SEC_INDEX and NAME. */
3854 sto_imm (bfd
*abfd
, asection
*section
,
3855 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3858 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3861 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3862 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3867 /* Try all the rest. */
3870 if (_bfd_vms_output_check (recwr
, size
) < 0)
3872 /* Doesn't fit, split ! */
3873 end_etir_record (abfd
);
3875 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3877 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3878 if (size
> ssize
) /* more than what's left ? */
3882 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3883 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3884 _bfd_vms_output_dump (recwr
, cptr
, size
);
3885 _bfd_vms_output_end_subrec (recwr
);
3888 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3889 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3899 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3901 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3903 /* Not enough room in this record. Close it and open a new one. */
3904 end_etir_record (abfd
);
3905 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3909 /* Return whether RELOC must be deferred till the end. */
3912 defer_reloc_p (arelent
*reloc
)
3914 switch (reloc
->howto
->type
)
3927 /* Write section contents for bfd abfd. Return FALSE on error. */
3930 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3933 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3935 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3937 _bfd_vms_output_alignment (recwr
, 4);
3939 PRIV (vms_linkage_index
) = 0;
3941 for (section
= abfd
->sections
; section
; section
= section
->next
)
3943 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3944 section
->target_index
, section
->name
, (int) (section
->size
)));
3946 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3947 || bfd_is_com_section (section
))
3950 if (!section
->contents
)
3952 bfd_set_error (bfd_error_no_contents
);
3956 start_etir_or_etbt_record (abfd
, section
, 0);
3958 if (section
->flags
& SEC_RELOC
)
3960 bfd_vma curr_addr
= 0;
3961 unsigned char *curr_data
= section
->contents
;
3963 int pass2_needed
= 0;
3964 int pass2_in_progress
= 0;
3967 if (section
->reloc_count
== 0)
3969 (_("SEC_RELOC with no relocs in section %pA"), section
);
3974 int i
= section
->reloc_count
;
3975 arelent
**rptr
= section
->orelocation
;
3976 _bfd_vms_debug (4, "%d relocations:\n", i
);
3979 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3980 "addr %08lx, off %08lx, len %d: %s\n",
3981 (*(*rptr
)->sym_ptr_ptr
)->name
,
3982 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3983 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3984 (unsigned long)(*rptr
)->address
,
3985 (unsigned long)(*rptr
)->addend
,
3986 bfd_get_reloc_size ((*rptr
)->howto
),
3987 ( *rptr
)->howto
->name
);
3994 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3996 struct evax_private_udata_struct
*udata
;
3997 arelent
*rptr
= section
->orelocation
[irel
];
3998 bfd_vma addr
= rptr
->address
;
3999 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
4000 asection
*sec
= sym
->section
;
4001 bfd_boolean defer
= defer_reloc_p (rptr
);
4004 if (pass2_in_progress
)
4006 /* Non-deferred relocs have already been output. */
4012 /* Deferred relocs must be output at the very end. */
4019 /* Regular relocs are intertwined with binary data. */
4020 if (curr_addr
> addr
)
4021 _bfd_error_handler (_("size error in section %pA"),
4023 size
= addr
- curr_addr
;
4024 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4029 size
= bfd_get_reloc_size (rptr
->howto
);
4031 switch (rptr
->howto
->type
)
4033 case ALPHA_R_IGNORE
:
4036 case ALPHA_R_REFLONG
:
4037 if (bfd_is_und_section (sym
->section
))
4039 bfd_vma addend
= rptr
->addend
;
4040 slen
= strlen ((char *) sym
->name
);
4041 etir_output_check (abfd
, section
, curr_addr
, slen
);
4044 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4045 _bfd_vms_output_counted (recwr
, sym
->name
);
4046 _bfd_vms_output_end_subrec (recwr
);
4047 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4048 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
4049 _bfd_vms_output_end_subrec (recwr
);
4050 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4051 _bfd_vms_output_end_subrec (recwr
);
4052 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4053 _bfd_vms_output_end_subrec (recwr
);
4057 _bfd_vms_output_begin_subrec
4058 (recwr
, ETIR__C_STO_GBL_LW
);
4059 _bfd_vms_output_counted (recwr
, sym
->name
);
4060 _bfd_vms_output_end_subrec (recwr
);
4063 else if (bfd_is_abs_section (sym
->section
))
4065 etir_output_check (abfd
, section
, curr_addr
, 16);
4066 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
4067 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
4068 _bfd_vms_output_end_subrec (recwr
);
4069 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4070 _bfd_vms_output_end_subrec (recwr
);
4074 etir_output_check (abfd
, section
, curr_addr
, 32);
4075 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4076 _bfd_vms_output_long (recwr
,
4077 (unsigned long) sec
->target_index
);
4078 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4079 _bfd_vms_output_end_subrec (recwr
);
4080 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
4081 says that we should have a ETIR__C_STO_OFF here.
4082 But the relocation would not be BFD_RELOC_32 then.
4083 This case is very likely unreachable. */
4084 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
4085 _bfd_vms_output_end_subrec (recwr
);
4089 case ALPHA_R_REFQUAD
:
4090 if (bfd_is_und_section (sym
->section
))
4092 bfd_vma addend
= rptr
->addend
;
4093 slen
= strlen ((char *) sym
->name
);
4094 etir_output_check (abfd
, section
, curr_addr
, slen
);
4097 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
4098 _bfd_vms_output_counted (recwr
, sym
->name
);
4099 _bfd_vms_output_end_subrec (recwr
);
4100 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4101 _bfd_vms_output_quad (recwr
, addend
);
4102 _bfd_vms_output_end_subrec (recwr
);
4103 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
4104 _bfd_vms_output_end_subrec (recwr
);
4105 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4106 _bfd_vms_output_end_subrec (recwr
);
4110 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
4111 _bfd_vms_output_counted (recwr
, sym
->name
);
4112 _bfd_vms_output_end_subrec (recwr
);
4115 else if (bfd_is_abs_section (sym
->section
))
4117 etir_output_check (abfd
, section
, curr_addr
, 16);
4118 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
4119 _bfd_vms_output_quad (recwr
, sym
->value
);
4120 _bfd_vms_output_end_subrec (recwr
);
4121 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
4122 _bfd_vms_output_end_subrec (recwr
);
4126 etir_output_check (abfd
, section
, curr_addr
, 32);
4127 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
4128 _bfd_vms_output_long (recwr
,
4129 (unsigned long) sec
->target_index
);
4130 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
4131 _bfd_vms_output_end_subrec (recwr
);
4132 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
4133 _bfd_vms_output_end_subrec (recwr
);
4138 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4141 case ALPHA_R_LINKAGE
:
4143 etir_output_check (abfd
, section
, curr_addr
, 64);
4144 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
4145 _bfd_vms_output_long
4146 (recwr
, (unsigned long) rptr
->addend
);
4147 if (rptr
->addend
> PRIV (vms_linkage_index
))
4148 PRIV (vms_linkage_index
) = rptr
->addend
;
4149 _bfd_vms_output_counted (recwr
, sym
->name
);
4150 _bfd_vms_output_byte (recwr
, 0);
4151 _bfd_vms_output_end_subrec (recwr
);
4154 case ALPHA_R_CODEADDR
:
4155 slen
= strlen ((char *) sym
->name
);
4156 etir_output_check (abfd
, section
, curr_addr
, slen
);
4157 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
4158 _bfd_vms_output_counted (recwr
, sym
->name
);
4159 _bfd_vms_output_end_subrec (recwr
);
4164 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4165 etir_output_check (abfd
, section
, curr_addr
,
4166 32 + 1 + strlen (udata
->origname
));
4167 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
4168 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4169 _bfd_vms_output_long
4170 (recwr
, (unsigned long) section
->target_index
);
4171 _bfd_vms_output_quad (recwr
, rptr
->address
);
4172 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
4173 _bfd_vms_output_long
4174 (recwr
, (unsigned long) section
->target_index
);
4175 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4176 _bfd_vms_output_counted (recwr
, udata
->origname
);
4177 _bfd_vms_output_end_subrec (recwr
);
4181 _bfd_error_handler (_("spurious ALPHA_R_BSR reloc"));
4186 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4187 etir_output_check (abfd
, section
, curr_addr
,
4188 32 + 1 + strlen (udata
->origname
));
4189 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4190 _bfd_vms_output_long
4191 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4192 _bfd_vms_output_long
4193 (recwr
, (unsigned long) section
->target_index
);
4194 _bfd_vms_output_quad (recwr
, rptr
->address
);
4195 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4196 _bfd_vms_output_long
4197 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4198 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4199 _bfd_vms_output_counted (recwr
, udata
->origname
);
4200 _bfd_vms_output_end_subrec (recwr
);
4205 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4206 etir_output_check (abfd
, section
, curr_addr
,
4207 32 + 1 + strlen (udata
->origname
));
4208 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4209 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4210 _bfd_vms_output_long
4211 (recwr
, (unsigned long) section
->target_index
);
4212 _bfd_vms_output_quad (recwr
, rptr
->address
);
4213 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4214 _bfd_vms_output_long
4215 (recwr
, (unsigned long) section
->target_index
);
4216 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4217 _bfd_vms_output_counted (recwr
, udata
->origname
);
4218 _bfd_vms_output_end_subrec (recwr
);
4222 _bfd_error_handler (_("unhandled relocation %s"),
4229 } /* End of relocs loop. */
4231 if (!pass2_in_progress
)
4233 /* Output rest of section. */
4234 if (curr_addr
> section
->size
)
4236 _bfd_error_handler (_("size error in section %pA"), section
);
4239 size
= section
->size
- curr_addr
;
4240 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4246 pass2_in_progress
= 1;
4252 else /* (section->flags & SEC_RELOC) */
4253 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4255 end_etir_record (abfd
);
4258 _bfd_vms_output_alignment (recwr
, 2);
4262 /* Write cached information into a file being written, at bfd_close. */
4265 alpha_vms_write_object_contents (bfd
*abfd
)
4267 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4269 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4271 return alpha_vms_write_exec (abfd
);
4275 if (abfd
->section_count
> 0) /* we have sections */
4277 if (!_bfd_vms_write_ehdr (abfd
))
4279 if (!_bfd_vms_write_egsd (abfd
))
4281 if (!_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
))
4283 if (!_bfd_vms_write_eeom (abfd
))
4290 /* Debug stuff: nearest line. */
4292 #define SET_MODULE_PARSED(m) \
4293 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4294 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4296 /* Build a new module for the specified BFD. */
4298 static struct module
*
4299 new_module (bfd
*abfd
)
4301 struct module
*module
4302 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4303 module
->file_table_count
= 16; /* Arbitrary. */
4305 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4309 /* Parse debug info for a module and internalize it. */
4312 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4315 unsigned char *maxptr
= ptr
+ length
;
4316 unsigned char *src_ptr
, *pcl_ptr
;
4317 unsigned int prev_linum
= 0, curr_linenum
= 0;
4318 bfd_vma prev_pc
= 0, curr_pc
= 0;
4319 struct srecinfo
*curr_srec
, *srec
;
4320 struct lineinfo
*curr_line
, *line
;
4321 struct funcinfo
*funcinfo
;
4323 /* Initialize tables with zero element. */
4324 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4325 module
->srec_table
= curr_srec
;
4327 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4328 module
->line_table
= curr_line
;
4330 while (length
== -1 || ptr
< maxptr
)
4332 /* The first byte is not counted in the recorded length. */
4333 int rec_length
= bfd_getl16 (ptr
) + 1;
4334 int rec_type
= bfd_getl16 (ptr
+ 2);
4336 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4338 if (length
== -1 && rec_type
== DST__K_MODEND
)
4345 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_MODBEG_NAME
,
4346 maxptr
- (ptr
+ DST_S_B_MODBEG_NAME
));
4353 vms_debug2 ((3, "module: %s\n", module
->name
));
4360 funcinfo
= (struct funcinfo
*)
4361 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4363 = _bfd_vms_save_counted_string (abfd
, ptr
+ DST_S_B_RTNBEG_NAME
,
4364 maxptr
- (ptr
+ DST_S_B_RTNBEG_NAME
));
4365 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4366 funcinfo
->next
= module
->func_table
;
4367 module
->func_table
= funcinfo
;
4369 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4370 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4374 module
->func_table
->high
= module
->func_table
->low
4375 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4377 if (module
->func_table
->high
> module
->high
)
4378 module
->high
= module
->func_table
->high
;
4380 vms_debug2 ((3, "end routine\n"));
4384 vms_debug2 ((3, "prologue\n"));
4388 vms_debug2 ((3, "epilog\n"));
4392 vms_debug2 ((3, "block\n"));
4396 vms_debug2 ((3, "end block\n"));
4400 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4402 vms_debug2 ((3, "source info\n"));
4404 while (src_ptr
< ptr
+ rec_length
)
4406 int cmd
= src_ptr
[0], cmd_length
, data
;
4410 case DST__K_SRC_DECLFILE
:
4413 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4414 char *filename
= _bfd_vms_save_counted_string
4416 src_ptr
+ DST_S_B_SRC_DF_FILENAME
,
4417 ptr
+ rec_length
- (src_ptr
+ DST_S_B_SRC_DF_FILENAME
));
4419 while (fileid
>= module
->file_table_count
)
4421 module
->file_table_count
*= 2;
4423 = bfd_realloc_or_free (module
->file_table
,
4424 module
->file_table_count
4425 * sizeof (struct fileinfo
));
4426 if (module
->file_table
== NULL
)
4430 module
->file_table
[fileid
].name
= filename
;
4431 module
->file_table
[fileid
].srec
= 1;
4432 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4433 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4434 fileid
, module
->file_table
[fileid
].name
));
4438 case DST__K_SRC_DEFLINES_B
:
4439 /* Perform the association and set the next higher index
4441 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4442 srec
= (struct srecinfo
*)
4443 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4444 srec
->line
= curr_srec
->line
+ data
;
4445 srec
->srec
= curr_srec
->srec
+ data
;
4446 srec
->sfile
= curr_srec
->sfile
;
4447 curr_srec
->next
= srec
;
4450 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4453 case DST__K_SRC_DEFLINES_W
:
4454 /* Perform the association and set the next higher index
4456 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4457 srec
= (struct srecinfo
*)
4458 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4459 srec
->line
= curr_srec
->line
+ data
;
4460 srec
->srec
= curr_srec
->srec
+ data
,
4461 srec
->sfile
= curr_srec
->sfile
;
4462 curr_srec
->next
= srec
;
4465 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4468 case DST__K_SRC_INCRLNUM_B
:
4469 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4470 curr_srec
->line
+= data
;
4472 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4475 case DST__K_SRC_SETFILE
:
4476 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4477 curr_srec
->sfile
= data
;
4478 curr_srec
->srec
= module
->file_table
[data
].srec
;
4480 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4483 case DST__K_SRC_SETLNUM_L
:
4484 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4485 curr_srec
->line
= data
;
4487 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4490 case DST__K_SRC_SETLNUM_W
:
4491 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4492 curr_srec
->line
= data
;
4494 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4497 case DST__K_SRC_SETREC_L
:
4498 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4499 curr_srec
->srec
= data
;
4500 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4502 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4505 case DST__K_SRC_SETREC_W
:
4506 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4507 curr_srec
->srec
= data
;
4508 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4510 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4513 case DST__K_SRC_FORMFEED
:
4515 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4519 _bfd_error_handler (_("unknown source command %d"),
4525 src_ptr
+= cmd_length
;
4529 case DST__K_LINE_NUM
:
4530 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4532 vms_debug2 ((3, "line info\n"));
4534 while (pcl_ptr
< ptr
+ rec_length
)
4536 /* The command byte is signed so we must sign-extend it. */
4537 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4541 case DST__K_DELTA_PC_W
:
4542 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4546 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4549 case DST__K_DELTA_PC_L
:
4550 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4554 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4557 case DST__K_INCR_LINUM
:
4558 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4559 curr_linenum
+= data
;
4561 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4564 case DST__K_INCR_LINUM_W
:
4565 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4566 curr_linenum
+= data
;
4568 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4571 case DST__K_INCR_LINUM_L
:
4572 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4573 curr_linenum
+= data
;
4575 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4578 case DST__K_SET_LINUM_INCR
:
4580 (_("%s not implemented"), "DST__K_SET_LINUM_INCR");
4584 case DST__K_SET_LINUM_INCR_W
:
4586 (_("%s not implemented"), "DST__K_SET_LINUM_INCR_W");
4590 case DST__K_RESET_LINUM_INCR
:
4592 (_("%s not implemented"), "DST__K_RESET_LINUM_INCR");
4596 case DST__K_BEG_STMT_MODE
:
4598 (_("%s not implemented"), "DST__K_BEG_STMT_MODE");
4602 case DST__K_END_STMT_MODE
:
4604 (_("%s not implemented"), "DST__K_END_STMT_MODE");
4608 case DST__K_SET_LINUM_B
:
4609 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4610 curr_linenum
= data
;
4612 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4615 case DST__K_SET_LINUM
:
4616 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4617 curr_linenum
= data
;
4619 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4622 case DST__K_SET_LINUM_L
:
4623 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4624 curr_linenum
= data
;
4626 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4631 (_("%s not implemented"), "DST__K_SET_PC");
4635 case DST__K_SET_PC_W
:
4637 (_("%s not implemented"), "DST__K_SET_PC_W");
4641 case DST__K_SET_PC_L
:
4643 (_("%s not implemented"), "DST__K_SET_PC_L");
4647 case DST__K_SET_STMTNUM
:
4649 (_("%s not implemented"), "DST__K_SET_STMTNUM");
4654 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4657 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4661 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4664 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4668 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4671 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4674 case DST__K_SET_ABS_PC
:
4675 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4678 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4687 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4688 (unsigned long)curr_pc
, curr_linenum
));
4692 _bfd_error_handler (_("unknown line command %d"), cmd
);
4698 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4700 || cmd
== DST__K_DELTA_PC_L
4701 || cmd
== DST__K_DELTA_PC_W
)
4703 line
= (struct lineinfo
*)
4704 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4705 line
->address
= curr_pc
;
4706 line
->line
= curr_linenum
;
4708 curr_line
->next
= line
;
4711 prev_linum
= curr_linenum
;
4713 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4714 (unsigned long)curr_pc
, curr_linenum
));
4717 pcl_ptr
+= cmd_length
;
4721 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4722 vms_debug2 ((3, "undocumented type 0x17\n"));
4726 vms_debug2 ((3, "ignoring record\n"));
4734 /* Finalize tables with EOL marker. */
4735 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4736 srec
->line
= (unsigned int) -1;
4737 srec
->srec
= (unsigned int) -1;
4738 curr_srec
->next
= srec
;
4740 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4741 line
->line
= (unsigned int) -1;
4742 line
->address
= (bfd_vma
) -1;
4743 curr_line
->next
= line
;
4745 /* Advertise that this module has been parsed. This is needed
4746 because parsing can be either performed at module creation
4747 or deferred until debug info is consumed. */
4748 SET_MODULE_PARSED (module
);
4752 /* Build the list of modules for the specified BFD. */
4754 static struct module
*
4755 build_module_list (bfd
*abfd
)
4757 struct module
*module
, *list
= NULL
;
4760 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4762 /* We have a DMT section so this must be an image. Parse the
4763 section and build the list of modules. This is sufficient
4764 since we can compute the start address and the end address
4765 of every module from the section contents. */
4766 bfd_size_type size
= bfd_section_size (dmt
);
4767 unsigned char *ptr
, *end
;
4769 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4773 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4776 vms_debug2 ((2, "DMT\n"));
4782 /* Each header declares a module with its start offset and size
4783 of debug info in the DST section, as well as the count of
4784 program sections (i.e. address spans) it contains. */
4785 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4786 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4787 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4788 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4790 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4791 modbeg
, msize
, count
));
4793 /* We create a 'module' structure for each program section since
4794 we only support contiguous addresses in a 'module' structure.
4795 As a consequence, the actual debug info in the DST section is
4796 shared and can be parsed multiple times; that doesn't seem to
4797 cause problems in practice. */
4800 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4801 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4802 module
= new_module (abfd
);
4803 module
->modbeg
= modbeg
;
4804 module
->size
= msize
;
4805 module
->low
= start
;
4806 module
->high
= start
+ length
;
4807 module
->next
= list
;
4809 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4811 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4818 /* We don't have a DMT section so this must be an object. Parse
4819 the module right now in order to compute its start address and
4821 void *dst
= PRIV (dst_section
)->contents
;
4826 module
= new_module (abfd
);
4827 if (!parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1))
4835 /* Calculate and return the name of the source file and the line nearest
4836 to the wanted location in the specified module. */
4839 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4840 const char **file
, const char **func
,
4843 struct funcinfo
*funcinfo
;
4844 struct lineinfo
*lineinfo
;
4845 struct srecinfo
*srecinfo
;
4846 bfd_boolean ret
= FALSE
;
4848 /* Parse this module if that was not done at module creation. */
4849 if (! IS_MODULE_PARSED (module
))
4851 unsigned int size
= module
->size
;
4852 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4853 unsigned char *buffer
;
4855 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4856 || (buffer
= _bfd_malloc_and_read (abfd
, size
, size
)) == NULL
)
4858 bfd_set_error (bfd_error_no_debug_section
);
4862 ret
= parse_module (abfd
, module
, buffer
, size
);
4868 /* Find out the function (if any) that contains the address. */
4869 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4870 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4872 *func
= funcinfo
->name
;
4877 /* Find out the source file and the line nearest to the address. */
4878 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4879 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4881 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4882 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4884 if (srecinfo
->sfile
> 0)
4886 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4887 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4891 *file
= module
->name
;
4892 *line
= lineinfo
->line
;
4903 /* Provided a BFD, a section and an offset into the section, calculate and
4904 return the name of the source file and the line nearest to the wanted
4908 _bfd_vms_find_nearest_line (bfd
*abfd
,
4909 asymbol
**symbols ATTRIBUTE_UNUSED
,
4915 unsigned int *discriminator
)
4917 struct module
*module
;
4919 /* What address are we looking for? */
4920 bfd_vma addr
= section
->vma
+ offset
;
4928 /* We can't do anything if there is no DST (debug symbol table). */
4929 if (PRIV (dst_section
) == NULL
)
4932 /* Create the module list - if not already done. */
4933 if (PRIV (modules
) == NULL
)
4935 PRIV (modules
) = build_module_list (abfd
);
4936 if (PRIV (modules
) == NULL
)
4940 for (module
= PRIV (modules
); module
; module
= module
->next
)
4941 if (addr
>= module
->low
&& addr
<= module
->high
)
4942 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4947 /* Canonicalizations. */
4948 /* Set name, value, section and flags of SYM from E. */
4951 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4960 flags
= BSF_NO_FLAGS
;
4966 if (e
->flags
& EGSY__V_WEAK
)
4969 if (e
->flags
& EGSY__V_DEF
)
4971 /* Symbol definition. */
4972 flags
|= BSF_GLOBAL
;
4973 if (e
->flags
& EGSY__V_NORM
)
4974 flags
|= BSF_FUNCTION
;
4980 /* Symbol reference. */
4981 sec
= bfd_und_section_ptr
;
4986 /* A universal symbol is by definition global... */
4987 flags
|= BSF_GLOBAL
;
4989 /* ...and dynamic in shared libraries. */
4990 if (abfd
->flags
& DYNAMIC
)
4991 flags
|= BSF_DYNAMIC
;
4993 if (e
->flags
& EGSY__V_WEAK
)
4996 if (!(e
->flags
& EGSY__V_DEF
))
4999 if (e
->flags
& EGSY__V_NORM
)
5000 flags
|= BSF_FUNCTION
;
5003 /* sec = e->section; */
5004 sec
= bfd_abs_section_ptr
;
5019 /* Return the number of bytes required to store a vector of pointers
5020 to asymbols for all the symbols in the BFD abfd, including a
5021 terminal NULL pointer. If there are no symbols in the BFD,
5022 then return 0. If an error occurs, return -1. */
5025 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
5027 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
5028 abfd
, PRIV (gsd_sym_count
)));
5030 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
5033 /* Read the symbols from the BFD abfd, and fills in the vector
5034 location with pointers to the symbols and a trailing NULL.
5036 Return number of symbols read. */
5039 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
5043 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
5045 if (PRIV (csymbols
) == NULL
)
5047 PRIV (csymbols
) = (asymbol
**) bfd_alloc
5048 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
5050 /* Traverse table and fill symbols vector. */
5051 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5053 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5056 sym
= bfd_make_empty_symbol (abfd
);
5057 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
5059 bfd_release (abfd
, PRIV (csymbols
));
5060 PRIV (csymbols
) = NULL
;
5064 PRIV (csymbols
)[i
] = sym
;
5068 if (symbols
!= NULL
)
5070 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5071 symbols
[i
] = PRIV (csymbols
)[i
];
5075 return PRIV (gsd_sym_count
);
5078 /* Read and convert relocations from ETIR. We do it once for all sections. */
5081 alpha_vms_slurp_relocs (bfd
*abfd
)
5085 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
5087 /* We slurp relocs only once, for all sections. */
5088 if (PRIV (reloc_done
))
5090 PRIV (reloc_done
) = TRUE
;
5092 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
5095 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
5100 unsigned char *begin
;
5103 bfd_reloc_code_real_type reloc_code
;
5109 bfd_vma cur_address
;
5111 unsigned char *cur_sym
= NULL
;
5113 bfd_vma cur_addend
= 0;
5115 /* Skip non-ETIR records. */
5116 type
= _bfd_vms_get_object_record (abfd
);
5117 if (type
== EOBJ__C_EEOM
)
5119 if (type
!= EOBJ__C_ETIR
)
5122 begin
= PRIV (recrd
.rec
) + 4;
5123 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
5125 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
5129 cmd
= bfd_getl16 (ptr
);
5130 length
= bfd_getl16 (ptr
+ 2);
5132 cur_address
= vaddr
;
5134 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
5135 _bfd_vms_etir_name (cmd
)));
5139 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
5140 /* ALPHA_R_REFQUAD und_section, step 1 */
5145 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
5146 cur_psidx
= bfd_getl32 (ptr
+ 4);
5147 cur_addend
= bfd_getl64 (ptr
+ 8);
5151 case ETIR__C_CTL_SETRB
:
5152 if (prev_cmd
!= ETIR__C_STA_PQ
)
5155 /* xgettext:c-format */
5156 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
5157 _bfd_vms_etir_name (cmd
));
5160 cur_psect
= cur_psidx
;
5166 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
5167 /* ALPHA_R_REFLONG und_section, step 2 */
5170 if (prev_cmd
!= ETIR__C_STA_GBL
)
5173 /* xgettext:c-format */
5174 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5175 _bfd_vms_etir_name (ETIR__C_STA_LW
));
5179 cur_addend
= bfd_getl32 (ptr
+ 4);
5183 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
5184 /* ALPHA_R_REFQUAD und_section, step 2 */
5185 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
5188 /* xgettext:c-format */
5189 (_("unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
5190 _bfd_vms_etir_name (ETIR__C_STA_QW
));
5193 cur_addend
= bfd_getl64 (ptr
+ 4);
5197 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
5198 /* ALPHA_R_REFLONG abs_section, step 2 */
5199 /* ALPHA_R_REFLONG others, step 2 */
5200 if (prev_cmd
!= ETIR__C_OPR_ADD
5201 && prev_cmd
!= ETIR__C_STA_LW
5202 && prev_cmd
!= ETIR__C_STA_PQ
)
5204 /* xgettext:c-format */
5205 _bfd_error_handler (_("unknown reloc %s + %s"),
5206 _bfd_vms_etir_name (prev_cmd
),
5207 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5210 reloc_code
= BFD_RELOC_32
;
5213 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5214 /* ALPHA_R_REFQUAD abs_section, step 2 */
5215 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5217 /* xgettext:c-format */
5218 _bfd_error_handler (_("unknown reloc %s + %s"),
5219 _bfd_vms_etir_name (prev_cmd
),
5220 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5223 reloc_code
= BFD_RELOC_64
;
5226 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5227 if (prev_cmd
!= ETIR__C_STA_PQ
)
5229 /* xgettext:c-format */
5230 _bfd_error_handler (_("unknown reloc %s + %s"),
5231 _bfd_vms_etir_name (prev_cmd
),
5232 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5235 reloc_code
= BFD_RELOC_64
;
5238 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5239 /* ALPHA_R_REFQUAD und_section, step 3 */
5240 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5242 /* xgettext:c-format */
5243 _bfd_error_handler (_("unknown reloc %s + %s"),
5244 _bfd_vms_etir_name (prev_cmd
),
5245 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5248 prev_cmd
= ETIR__C_OPR_ADD
;
5251 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5252 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5256 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5257 reloc_code
= BFD_RELOC_64
;
5261 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5262 reloc_code
= BFD_RELOC_32
;
5266 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5267 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5271 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5272 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5275 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5276 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5279 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5280 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5283 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5284 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5288 cur_sym
= ptr
+ 4 + 32;
5289 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5290 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5293 case ETIR__C_STO_IMM
:
5294 vaddr
+= bfd_getl32 (ptr
+ 4);
5298 _bfd_error_handler (_("unknown reloc %s"),
5299 _bfd_vms_etir_name (cmd
));
5305 struct vms_section_data_struct
*vms_sec
;
5309 /* Get section to which the relocation applies. */
5310 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5312 _bfd_error_handler (_("invalid section index in ETIR"));
5316 if (PRIV (sections
) == NULL
)
5318 sec
= PRIV (sections
)[cur_psect
];
5319 if (sec
== bfd_abs_section_ptr
)
5321 _bfd_error_handler (_("relocation for non-REL psect"));
5325 vms_sec
= vms_section_data (sec
);
5327 /* Allocate a reloc entry. */
5328 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5330 if (vms_sec
->reloc_max
== 0)
5332 vms_sec
->reloc_max
= 64;
5333 sec
->relocation
= bfd_zmalloc
5334 (vms_sec
->reloc_max
* sizeof (arelent
));
5338 vms_sec
->reloc_max
*= 2;
5339 sec
->relocation
= bfd_realloc_or_free
5340 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5341 if (sec
->relocation
== NULL
)
5345 reloc
= &sec
->relocation
[sec
->reloc_count
];
5348 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5350 if (cur_sym
!= NULL
)
5353 unsigned int symlen
= *cur_sym
;
5356 /* Linear search. */
5361 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5362 if (PRIV (syms
)[j
]->namelen
== symlen
5363 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5365 sym
= &PRIV (csymbols
)[j
];
5370 _bfd_error_handler (_("unknown symbol in command %s"),
5371 _bfd_vms_etir_name (cmd
));
5372 reloc
->sym_ptr_ptr
= NULL
;
5375 reloc
->sym_ptr_ptr
= sym
;
5377 else if (cur_psidx
>= 0)
5379 if (PRIV (sections
) == NULL
|| cur_psidx
>= (int) PRIV (section_count
))
5381 reloc
->sym_ptr_ptr
=
5382 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5385 reloc
->sym_ptr_ptr
= NULL
;
5387 reloc
->address
= cur_address
;
5388 reloc
->addend
= cur_addend
;
5390 if (reloc_code
== ALPHA_R_LINKAGE
)
5393 size
= bfd_get_reloc_size (reloc
->howto
);
5403 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5408 /* Return the number of bytes required to store the relocation
5409 information associated with the given section. */
5412 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5414 alpha_vms_slurp_relocs (abfd
);
5416 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5419 /* Convert relocations from VMS (external) form into BFD internal
5420 form. Return the number of relocations. */
5423 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5424 asymbol
**symbols ATTRIBUTE_UNUSED
)
5429 if (!alpha_vms_slurp_relocs (abfd
))
5432 count
= section
->reloc_count
;
5433 tblptr
= section
->relocation
;
5436 *relptr
++ = tblptr
++;
5438 *relptr
= (arelent
*) NULL
;
5439 return section
->reloc_count
;
5442 /* Install a new set of internal relocs. */
5444 #define alpha_vms_set_reloc _bfd_generic_set_reloc
5447 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5449 /* How to process the various reloc types. */
5451 static bfd_reloc_status_type
5452 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5453 arelent
*reloc ATTRIBUTE_UNUSED
,
5454 asymbol
*sym ATTRIBUTE_UNUSED
,
5455 void * data ATTRIBUTE_UNUSED
,
5456 asection
*sec ATTRIBUTE_UNUSED
,
5457 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5458 char **error_message ATTRIBUTE_UNUSED
)
5461 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5462 vms_debug (2, "In section %s, symbol %s\n",
5463 sec
->name
, sym
->name
);
5464 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5465 reloc
->sym_ptr_ptr
[0]->name
,
5466 (unsigned long)reloc
->address
,
5467 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5468 vms_debug (2, "data at %p\n", data
);
5469 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5472 return bfd_reloc_ok
;
5475 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5476 from smaller values. Start with zero, widen, *then* decrement. */
5477 #define MINUS_ONE (((bfd_vma)0) - 1)
5479 static reloc_howto_type alpha_howto_table
[] =
5481 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5482 0, /* Rightshift. */
5483 0, /* Size (0 = byte, 1 = short, 2 = long). */
5485 TRUE
, /* PC relative. */
5487 complain_overflow_dont
,/* Complain_on_overflow. */
5488 reloc_nil
, /* Special_function. */
5489 "IGNORE", /* Name. */
5490 TRUE
, /* Partial_inplace. */
5491 0, /* Source mask */
5493 TRUE
), /* PC rel offset. */
5495 /* A 64 bit reference to a symbol. */
5496 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5497 0, /* Rightshift. */
5498 4, /* Size (0 = byte, 1 = short, 2 = long). */
5500 FALSE
, /* PC relative. */
5502 complain_overflow_bitfield
, /* Complain_on_overflow. */
5503 reloc_nil
, /* Special_function. */
5504 "REFQUAD", /* Name. */
5505 TRUE
, /* Partial_inplace. */
5506 MINUS_ONE
, /* Source mask. */
5507 MINUS_ONE
, /* Dest mask. */
5508 FALSE
), /* PC rel offset. */
5510 /* A 21 bit branch. The native assembler generates these for
5511 branches within the text segment, and also fills in the PC
5512 relative offset in the instruction. */
5513 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5514 2, /* Rightshift. */
5515 2, /* Size (0 = byte, 1 = short, 2 = long). */
5517 TRUE
, /* PC relative. */
5519 complain_overflow_signed
, /* Complain_on_overflow. */
5520 reloc_nil
, /* Special_function. */
5521 "BRADDR", /* Name. */
5522 TRUE
, /* Partial_inplace. */
5523 0x1fffff, /* Source mask. */
5524 0x1fffff, /* Dest mask. */
5525 FALSE
), /* PC rel offset. */
5527 /* A hint for a jump to a register. */
5528 HOWTO (ALPHA_R_HINT
, /* Type. */
5529 2, /* Rightshift. */
5530 1, /* Size (0 = byte, 1 = short, 2 = long). */
5532 TRUE
, /* PC relative. */
5534 complain_overflow_dont
,/* Complain_on_overflow. */
5535 reloc_nil
, /* Special_function. */
5537 TRUE
, /* Partial_inplace. */
5538 0x3fff, /* Source mask. */
5539 0x3fff, /* Dest mask. */
5540 FALSE
), /* PC rel offset. */
5542 /* 16 bit PC relative offset. */
5543 HOWTO (ALPHA_R_SREL16
, /* Type. */
5544 0, /* Rightshift. */
5545 1, /* Size (0 = byte, 1 = short, 2 = long). */
5547 TRUE
, /* PC relative. */
5549 complain_overflow_signed
, /* Complain_on_overflow. */
5550 reloc_nil
, /* Special_function. */
5551 "SREL16", /* Name. */
5552 TRUE
, /* Partial_inplace. */
5553 0xffff, /* Source mask. */
5554 0xffff, /* Dest mask. */
5555 FALSE
), /* PC rel offset. */
5557 /* 32 bit PC relative offset. */
5558 HOWTO (ALPHA_R_SREL32
, /* Type. */
5559 0, /* Rightshift. */
5560 2, /* Size (0 = byte, 1 = short, 2 = long). */
5562 TRUE
, /* PC relative. */
5564 complain_overflow_signed
, /* Complain_on_overflow. */
5565 reloc_nil
, /* Special_function. */
5566 "SREL32", /* Name. */
5567 TRUE
, /* Partial_inplace. */
5568 0xffffffff, /* Source mask. */
5569 0xffffffff, /* Dest mask. */
5570 FALSE
), /* PC rel offset. */
5572 /* A 64 bit PC relative offset. */
5573 HOWTO (ALPHA_R_SREL64
, /* Type. */
5574 0, /* Rightshift. */
5575 4, /* Size (0 = byte, 1 = short, 2 = long). */
5577 TRUE
, /* PC relative. */
5579 complain_overflow_signed
, /* Complain_on_overflow. */
5580 reloc_nil
, /* Special_function. */
5581 "SREL64", /* Name. */
5582 TRUE
, /* Partial_inplace. */
5583 MINUS_ONE
, /* Source mask. */
5584 MINUS_ONE
, /* Dest mask. */
5585 FALSE
), /* PC rel offset. */
5587 /* Push a value on the reloc evaluation stack. */
5588 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5589 0, /* Rightshift. */
5590 0, /* Size (0 = byte, 1 = short, 2 = long). */
5592 FALSE
, /* PC relative. */
5594 complain_overflow_dont
,/* Complain_on_overflow. */
5595 reloc_nil
, /* Special_function. */
5596 "OP_PUSH", /* Name. */
5597 FALSE
, /* Partial_inplace. */
5598 0, /* Source mask. */
5600 FALSE
), /* PC rel offset. */
5602 /* Store the value from the stack at the given address. Store it in
5603 a bitfield of size r_size starting at bit position r_offset. */
5604 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5605 0, /* Rightshift. */
5606 4, /* Size (0 = byte, 1 = short, 2 = long). */
5608 FALSE
, /* PC relative. */
5610 complain_overflow_dont
,/* Complain_on_overflow. */
5611 reloc_nil
, /* Special_function. */
5612 "OP_STORE", /* Name. */
5613 FALSE
, /* Partial_inplace. */
5614 0, /* Source mask. */
5615 MINUS_ONE
, /* Dest mask. */
5616 FALSE
), /* PC rel offset. */
5618 /* Subtract the reloc address from the value on the top of the
5619 relocation stack. */
5620 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5621 0, /* Rightshift. */
5622 0, /* Size (0 = byte, 1 = short, 2 = long). */
5624 FALSE
, /* PC relative. */
5626 complain_overflow_dont
,/* Complain_on_overflow. */
5627 reloc_nil
, /* Special_function. */
5628 "OP_PSUB", /* Name. */
5629 FALSE
, /* Partial_inplace. */
5630 0, /* Source mask. */
5632 FALSE
), /* PC rel offset. */
5634 /* Shift the value on the top of the relocation stack right by the
5636 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5637 0, /* Rightshift. */
5638 0, /* Size (0 = byte, 1 = short, 2 = long). */
5640 FALSE
, /* PC relative. */
5642 complain_overflow_dont
,/* Complain_on_overflow. */
5643 reloc_nil
, /* Special_function. */
5644 "OP_PRSHIFT", /* Name. */
5645 FALSE
, /* Partial_inplace. */
5646 0, /* Source mask. */
5648 FALSE
), /* PC rel offset. */
5650 /* Hack. Linkage is done by linker. */
5651 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5652 0, /* Rightshift. */
5653 0, /* Size (0 = byte, 1 = short, 2 = long). */
5655 FALSE
, /* PC relative. */
5657 complain_overflow_dont
,/* Complain_on_overflow. */
5658 reloc_nil
, /* Special_function. */
5659 "LINKAGE", /* Name. */
5660 FALSE
, /* Partial_inplace. */
5661 0, /* Source mask. */
5663 FALSE
), /* PC rel offset. */
5665 /* A 32 bit reference to a symbol. */
5666 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5667 0, /* Rightshift. */
5668 2, /* Size (0 = byte, 1 = short, 2 = long). */
5670 FALSE
, /* PC relative. */
5672 complain_overflow_bitfield
, /* Complain_on_overflow. */
5673 reloc_nil
, /* Special_function. */
5674 "REFLONG", /* Name. */
5675 TRUE
, /* Partial_inplace. */
5676 0xffffffff, /* Source mask. */
5677 0xffffffff, /* Dest mask. */
5678 FALSE
), /* PC rel offset. */
5680 /* A 64 bit reference to a procedure, written as 32 bit value. */
5681 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5682 0, /* Rightshift. */
5683 4, /* Size (0 = byte, 1 = short, 2 = long). */
5685 FALSE
, /* PC relative. */
5687 complain_overflow_signed
,/* Complain_on_overflow. */
5688 reloc_nil
, /* Special_function. */
5689 "CODEADDR", /* Name. */
5690 FALSE
, /* Partial_inplace. */
5691 0xffffffff, /* Source mask. */
5692 0xffffffff, /* Dest mask. */
5693 FALSE
), /* PC rel offset. */
5695 HOWTO (ALPHA_R_NOP
, /* Type. */
5696 0, /* Rightshift. */
5697 3, /* Size (0 = byte, 1 = short, 2 = long). */
5699 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5700 because the calculations for the 3 relocations are the same.
5701 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5702 TRUE
, /* PC relative. */
5704 complain_overflow_dont
,/* Complain_on_overflow. */
5705 reloc_nil
, /* Special_function. */
5707 FALSE
, /* Partial_inplace. */
5708 0xffffffff, /* Source mask. */
5709 0xffffffff, /* Dest mask. */
5710 FALSE
), /* PC rel offset. */
5712 HOWTO (ALPHA_R_BSR
, /* Type. */
5713 0, /* Rightshift. */
5714 3, /* Size (0 = byte, 1 = short, 2 = long). */
5716 TRUE
, /* PC relative. */
5718 complain_overflow_dont
,/* Complain_on_overflow. */
5719 reloc_nil
, /* Special_function. */
5721 FALSE
, /* Partial_inplace. */
5722 0xffffffff, /* Source mask. */
5723 0xffffffff, /* Dest mask. */
5724 FALSE
), /* PC rel offset. */
5726 HOWTO (ALPHA_R_LDA
, /* Type. */
5727 0, /* Rightshift. */
5728 3, /* Size (0 = byte, 1 = short, 2 = long). */
5730 FALSE
, /* PC relative. */
5732 complain_overflow_dont
,/* Complain_on_overflow. */
5733 reloc_nil
, /* Special_function. */
5735 FALSE
, /* Partial_inplace. */
5736 0xffffffff, /* Source mask. */
5737 0xffffffff, /* Dest mask. */
5738 FALSE
), /* PC rel offset. */
5740 HOWTO (ALPHA_R_BOH
, /* Type. */
5741 0, /* Rightshift. */
5742 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5744 TRUE
, /* PC relative. */
5746 complain_overflow_dont
,/* Complain_on_overflow. */
5747 reloc_nil
, /* Special_function. */
5749 FALSE
, /* Partial_inplace. */
5750 0xffffffff, /* Source mask. */
5751 0xffffffff, /* Dest mask. */
5752 FALSE
), /* PC rel offset. */
5755 /* Return a pointer to a howto structure which, when invoked, will perform
5756 the relocation code on data from the architecture noted. */
5758 static reloc_howto_type
*
5759 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5760 bfd_reloc_code_real_type code
)
5764 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5768 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5769 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5770 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5771 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5772 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5773 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5774 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5775 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5776 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5777 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5778 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5779 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5780 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5781 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5782 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5784 _bfd_error_handler (_("reloc (%d) is *UNKNOWN*"), code
);
5787 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5788 return & alpha_howto_table
[alpha_type
];
5791 static reloc_howto_type
*
5792 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5798 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5800 if (alpha_howto_table
[i
].name
!= NULL
5801 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5802 return &alpha_howto_table
[i
];
5808 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5809 long symcount ATTRIBUTE_UNUSED
,
5810 asymbol
**usyms ATTRIBUTE_UNUSED
,
5811 long dynsymcount ATTRIBUTE_UNUSED
,
5812 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5819 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5824 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5826 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5837 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5844 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5846 value
= e
->code_value
;
5847 sec
= e
->code_section
;
5858 sname
= bfd_alloc (abfd
, l
+ 5);
5861 memcpy (sname
, name
, l
);
5862 memcpy (sname
+ l
, "..en", 5);
5869 sym
->udata
.p
= NULL
;
5878 vms_time_to_str (unsigned char *buf
)
5880 time_t t
= vms_rawtime_to_time_t (buf
);
5881 char *res
= ctime (&t
);
5884 res
= "*invalid time*";
5891 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5893 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5894 unsigned int subtype
;
5897 subtype
= (unsigned) bfd_getl16 (emh
->subtyp
);
5899 /* xgettext:c-format */
5900 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5902 /* PR 21618: Check for invalid lengths. */
5903 if (rec_len
< sizeof (* emh
))
5905 fprintf (file
, _(" Error: The length is less than the length of an EMH record\n"));
5908 extra
= rec_len
- sizeof (struct vms_emh_common
);
5914 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*) rec
;
5916 const char * nextname
;
5917 const char * maxname
;
5919 /* PR 21840: Check for invalid lengths. */
5920 if (rec_len
< sizeof (* mhd
))
5922 fprintf (file
, _(" Error: The record length is less than the size of an EMH_MHD record\n"));
5925 fprintf (file
, _("Module header\n"));
5926 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5927 fprintf (file
, _(" max record size: %u\n"),
5928 (unsigned) bfd_getl32 (mhd
->recsiz
));
5929 name
= (char *)(mhd
+ 1);
5930 maxname
= (char *) rec
+ rec_len
;
5931 if (name
> maxname
- 2)
5933 fprintf (file
, _(" Error: The module name is missing\n"));
5936 nextname
= name
+ name
[0] + 1;
5937 if (nextname
>= maxname
)
5939 fprintf (file
, _(" Error: The module name is too long\n"));
5942 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5944 if (name
> maxname
- 2)
5946 fprintf (file
, _(" Error: The module version is missing\n"));
5949 nextname
= name
+ name
[0] + 1;
5950 if (nextname
>= maxname
)
5952 fprintf (file
, _(" Error: The module version is too long\n"));
5955 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5957 if ((maxname
- name
) < 17 && maxname
[-1] != 0)
5958 fprintf (file
, _(" Error: The compile date is truncated\n"));
5960 fprintf (file
, _(" compile date : %.17s\n"), name
);
5965 fprintf (file
, _("Language Processor Name\n"));
5966 fprintf (file
, _(" language name: %.*s\n"), extra
, (char *)(emh
+ 1));
5970 fprintf (file
, _("Source Files Header\n"));
5971 fprintf (file
, _(" file: %.*s\n"), extra
, (char *)(emh
+ 1));
5975 fprintf (file
, _("Title Text Header\n"));
5976 fprintf (file
, _(" title: %.*s\n"), extra
, (char *)(emh
+ 1));
5980 fprintf (file
, _("Copyright Header\n"));
5981 fprintf (file
, _(" copyright: %.*s\n"), extra
, (char *)(emh
+ 1));
5985 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5991 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5993 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5995 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5997 /* PR 21618: Check for invalid lengths. */
5998 if (rec_len
< sizeof (* eeom
))
6000 fprintf (file
, _(" Error: The length is less than the length of an EEOM record\n"));
6004 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
6005 (unsigned)bfd_getl32 (eeom
->total_lps
));
6006 fprintf (file
, _(" completion code: %u\n"),
6007 (unsigned)bfd_getl16 (eeom
->comcod
));
6010 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
6011 fprintf (file
, _(" transfer addr psect: %u\n"),
6012 (unsigned)bfd_getl32 (eeom
->psindx
));
6013 fprintf (file
, _(" transfer address : 0x%08x\n"),
6014 (unsigned)bfd_getl32 (eeom
->tfradr
));
6019 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
6021 if (flags
& EGSY__V_WEAK
)
6022 fputs (_(" WEAK"), file
);
6023 if (flags
& EGSY__V_DEF
)
6024 fputs (_(" DEF"), file
);
6025 if (flags
& EGSY__V_UNI
)
6026 fputs (_(" UNI"), file
);
6027 if (flags
& EGSY__V_REL
)
6028 fputs (_(" REL"), file
);
6029 if (flags
& EGSY__V_COMM
)
6030 fputs (_(" COMM"), file
);
6031 if (flags
& EGSY__V_VECEP
)
6032 fputs (_(" VECEP"), file
);
6033 if (flags
& EGSY__V_NORM
)
6034 fputs (_(" NORM"), file
);
6035 if (flags
& EGSY__V_QUAD_VAL
)
6036 fputs (_(" QVAL"), file
);
6040 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
6042 if (flags
& EGPS__V_PIC
)
6043 fputs (_(" PIC"), file
);
6044 if (flags
& EGPS__V_LIB
)
6045 fputs (_(" LIB"), file
);
6046 if (flags
& EGPS__V_OVR
)
6047 fputs (_(" OVR"), file
);
6048 if (flags
& EGPS__V_REL
)
6049 fputs (_(" REL"), file
);
6050 if (flags
& EGPS__V_GBL
)
6051 fputs (_(" GBL"), file
);
6052 if (flags
& EGPS__V_SHR
)
6053 fputs (_(" SHR"), file
);
6054 if (flags
& EGPS__V_EXE
)
6055 fputs (_(" EXE"), file
);
6056 if (flags
& EGPS__V_RD
)
6057 fputs (_(" RD"), file
);
6058 if (flags
& EGPS__V_WRT
)
6059 fputs (_(" WRT"), file
);
6060 if (flags
& EGPS__V_VEC
)
6061 fputs (_(" VEC"), file
);
6062 if (flags
& EGPS__V_NOMOD
)
6063 fputs (_(" NOMOD"), file
);
6064 if (flags
& EGPS__V_COM
)
6065 fputs (_(" COM"), file
);
6066 if (flags
& EGPS__V_ALLOC_64BIT
)
6067 fputs (_(" 64B"), file
);
6071 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
6073 unsigned int off
= sizeof (struct vms_egsd
);
6076 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
6079 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
6081 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
6085 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
6086 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
6088 /* xgettext:c-format */
6089 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
6093 if (off
+ len
> rec_len
|| off
+ len
< off
)
6095 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6103 struct vms_egps
*egps
= (struct vms_egps
*)e
;
6104 unsigned int flags
= bfd_getl16 (egps
->flags
);
6107 fprintf (file
, _("PSC - Program section definition\n"));
6108 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
6109 fprintf (file
, _(" flags : 0x%04x"), flags
);
6110 evax_bfd_print_egsd_flags (file
, flags
);
6112 l
= bfd_getl32 (egps
->alloc
);
6113 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
6114 fprintf (file
, _(" name : %.*s\n"),
6115 egps
->namlng
, egps
->name
);
6120 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
6121 unsigned int flags
= bfd_getl16 (esgps
->flags
);
6124 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
6125 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
6126 fprintf (file
, _(" flags : 0x%04x"), flags
);
6127 evax_bfd_print_egsd_flags (file
, flags
);
6129 l
= bfd_getl32 (esgps
->alloc
);
6130 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
6131 fprintf (file
, _(" image offset : 0x%08x\n"),
6132 (unsigned int)bfd_getl32 (esgps
->base
));
6133 fprintf (file
, _(" symvec offset : 0x%08x\n"),
6134 (unsigned int)bfd_getl32 (esgps
->value
));
6135 fprintf (file
, _(" name : %.*s\n"),
6136 esgps
->namlng
, esgps
->name
);
6141 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
6142 unsigned int flags
= bfd_getl16 (egsy
->flags
);
6144 if (flags
& EGSY__V_DEF
)
6146 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
6148 fprintf (file
, _("SYM - Global symbol definition\n"));
6149 fprintf (file
, _(" flags: 0x%04x"), flags
);
6150 exav_bfd_print_egsy_flags (flags
, file
);
6152 fprintf (file
, _(" psect offset: 0x%08x\n"),
6153 (unsigned)bfd_getl32 (esdf
->value
));
6154 if (flags
& EGSY__V_NORM
)
6156 fprintf (file
, _(" code address: 0x%08x\n"),
6157 (unsigned)bfd_getl32 (esdf
->code_address
));
6158 fprintf (file
, _(" psect index for entry point : %u\n"),
6159 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
6161 fprintf (file
, _(" psect index : %u\n"),
6162 (unsigned)bfd_getl32 (esdf
->psindx
));
6163 fprintf (file
, _(" name : %.*s\n"),
6164 esdf
->namlng
, esdf
->name
);
6168 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
6170 fprintf (file
, _("SYM - Global symbol reference\n"));
6171 fprintf (file
, _(" name : %.*s\n"),
6172 esrf
->namlng
, esrf
->name
);
6178 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
6179 unsigned int flags
= bfd_getl32 (eidc
->flags
);
6182 fprintf (file
, _("IDC - Ident Consistency check\n"));
6183 fprintf (file
, _(" flags : 0x%08x"), flags
);
6184 if (flags
& EIDC__V_BINIDENT
)
6185 fputs (" BINDENT", file
);
6187 fprintf (file
, _(" id match : %x\n"),
6188 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
6189 fprintf (file
, _(" error severity: %x\n"),
6190 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
6192 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
6194 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
6196 if (flags
& EIDC__V_BINIDENT
)
6197 fprintf (file
, _(" binary ident : 0x%08x\n"),
6198 (unsigned)bfd_getl32 (p
+ 1));
6200 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
6205 struct vms_egst
*egst
= (struct vms_egst
*)e
;
6206 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
6208 fprintf (file
, _("SYMG - Universal symbol definition\n"));
6209 fprintf (file
, _(" flags: 0x%04x"), flags
);
6210 exav_bfd_print_egsy_flags (flags
, file
);
6212 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
6213 (unsigned)bfd_getl32 (egst
->value
));
6214 fprintf (file
, _(" entry point: 0x%08x\n"),
6215 (unsigned)bfd_getl32 (egst
->lp_1
));
6216 fprintf (file
, _(" proc descr : 0x%08x\n"),
6217 (unsigned)bfd_getl32 (egst
->lp_2
));
6218 fprintf (file
, _(" psect index: %u\n"),
6219 (unsigned)bfd_getl32 (egst
->psindx
));
6220 fprintf (file
, _(" name : %.*s\n"),
6221 egst
->namlng
, egst
->name
);
6226 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
6227 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
6229 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
6230 fprintf (file
, _(" flags: 0x%04x"), flags
);
6231 exav_bfd_print_egsy_flags (flags
, file
);
6233 fprintf (file
, _(" vector : 0x%08x\n"),
6234 (unsigned)bfd_getl32 (esdfv
->vector
));
6235 fprintf (file
, _(" psect offset: %u\n"),
6236 (unsigned)bfd_getl32 (esdfv
->value
));
6237 fprintf (file
, _(" psect index : %u\n"),
6238 (unsigned)bfd_getl32 (esdfv
->psindx
));
6239 fprintf (file
, _(" name : %.*s\n"),
6240 esdfv
->namlng
, esdfv
->name
);
6245 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
6246 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
6248 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
6249 fprintf (file
, _(" flags: 0x%04x"), flags
);
6250 exav_bfd_print_egsy_flags (flags
, file
);
6252 fprintf (file
, _(" version mask: 0x%08x\n"),
6253 (unsigned)bfd_getl32 (esdfm
->version_mask
));
6254 fprintf (file
, _(" psect offset: %u\n"),
6255 (unsigned)bfd_getl32 (esdfm
->value
));
6256 fprintf (file
, _(" psect index : %u\n"),
6257 (unsigned)bfd_getl32 (esdfm
->psindx
));
6258 fprintf (file
, _(" name : %.*s\n"),
6259 esdfm
->namlng
, esdfm
->name
);
6263 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
6271 evax_bfd_print_hex (FILE *file
, const char *pfx
,
6272 const unsigned char *buf
, unsigned int len
)
6278 for (i
= 0; i
< len
; i
++)
6282 fprintf (file
, " %02x", buf
[i
]);
6295 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6297 /* xgettext:c-format */
6298 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6299 (unsigned)bfd_getl32 (buf
),
6300 (unsigned)bfd_getl32 (buf
+ 16));
6301 /* xgettext:c-format */
6302 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6303 (unsigned)bfd_getl32 (buf
+ 4),
6304 (unsigned)bfd_getl32 (buf
+ 12),
6305 (unsigned)bfd_getl32 (buf
+ 8));
6306 /* xgettext:c-format */
6307 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6308 (unsigned)bfd_getl32 (buf
+ 20),
6309 (unsigned)bfd_getl32 (buf
+ 28),
6310 (unsigned)bfd_getl32 (buf
+ 24));
6312 /* xgettext:c-format */
6313 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6314 (unsigned)bfd_getl32 (buf
+ 32),
6315 (unsigned)bfd_getl32 (buf
+ 40),
6316 (unsigned)bfd_getl32 (buf
+ 36));
6318 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6322 evax_bfd_print_etir (FILE *file
, const char *name
,
6323 unsigned char *rec
, unsigned int rec_len
)
6325 unsigned int off
= sizeof (struct vms_egsd
);
6326 unsigned int sec_len
= 0;
6328 /* xgettext:c-format */
6329 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6330 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6331 (unsigned)sizeof (struct vms_eobjrec
));
6333 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6335 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6340 type
= bfd_getl16 (etir
->rectyp
);
6341 size
= bfd_getl16 (etir
->size
);
6342 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6344 if (off
+ size
> rec_len
|| off
+ size
< off
)
6346 fprintf (file
, _(" Error: length larger than remaining space in record\n"));
6350 /* xgettext:c-format */
6351 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6354 case ETIR__C_STA_GBL
:
6355 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6358 case ETIR__C_STA_LW
:
6359 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6360 (unsigned)bfd_getl32 (buf
));
6362 case ETIR__C_STA_QW
:
6363 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6364 (unsigned)bfd_getl32 (buf
+ 4),
6365 (unsigned)bfd_getl32 (buf
+ 0));
6367 case ETIR__C_STA_PQ
:
6368 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6369 /* xgettext:c-format */
6370 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6371 (unsigned)bfd_getl32 (buf
+ 0),
6372 (unsigned)bfd_getl32 (buf
+ 8),
6373 (unsigned)bfd_getl32 (buf
+ 4));
6375 case ETIR__C_STA_LI
:
6376 fprintf (file
, _("STA_LI (stack literal)\n"));
6378 case ETIR__C_STA_MOD
:
6379 fprintf (file
, _("STA_MOD (stack module)\n"));
6381 case ETIR__C_STA_CKARG
:
6382 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6386 fprintf (file
, _("STO_B (store byte)\n"));
6389 fprintf (file
, _("STO_W (store word)\n"));
6391 case ETIR__C_STO_LW
:
6392 fprintf (file
, _("STO_LW (store longword)\n"));
6394 case ETIR__C_STO_QW
:
6395 fprintf (file
, _("STO_QW (store quadword)\n"));
6397 case ETIR__C_STO_IMMR
:
6399 unsigned int len
= bfd_getl32 (buf
);
6401 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6403 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6407 case ETIR__C_STO_GBL
:
6408 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6411 case ETIR__C_STO_CA
:
6412 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6415 case ETIR__C_STO_RB
:
6416 fprintf (file
, _("STO_RB (store relative branch)\n"));
6418 case ETIR__C_STO_AB
:
6419 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6421 case ETIR__C_STO_OFF
:
6422 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6424 case ETIR__C_STO_IMM
:
6426 unsigned int len
= bfd_getl32 (buf
);
6428 _("STO_IMM (store immediate) %u bytes\n"),
6430 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6434 case ETIR__C_STO_GBL_LW
:
6435 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6438 case ETIR__C_STO_LP_PSB
:
6439 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6441 case ETIR__C_STO_HINT_GBL
:
6442 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6444 case ETIR__C_STO_HINT_PS
:
6445 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6448 case ETIR__C_OPR_NOP
:
6449 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6451 case ETIR__C_OPR_ADD
:
6452 fprintf (file
, _("OPR_ADD (add)\n"));
6454 case ETIR__C_OPR_SUB
:
6455 fprintf (file
, _("OPR_SUB (subtract)\n"));
6457 case ETIR__C_OPR_MUL
:
6458 fprintf (file
, _("OPR_MUL (multiply)\n"));
6460 case ETIR__C_OPR_DIV
:
6461 fprintf (file
, _("OPR_DIV (divide)\n"));
6463 case ETIR__C_OPR_AND
:
6464 fprintf (file
, _("OPR_AND (logical and)\n"));
6466 case ETIR__C_OPR_IOR
:
6467 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6469 case ETIR__C_OPR_EOR
:
6470 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6472 case ETIR__C_OPR_NEG
:
6473 fprintf (file
, _("OPR_NEG (negate)\n"));
6475 case ETIR__C_OPR_COM
:
6476 fprintf (file
, _("OPR_COM (complement)\n"));
6478 case ETIR__C_OPR_INSV
:
6479 fprintf (file
, _("OPR_INSV (insert field)\n"));
6481 case ETIR__C_OPR_ASH
:
6482 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6484 case ETIR__C_OPR_USH
:
6485 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6487 case ETIR__C_OPR_ROT
:
6488 fprintf (file
, _("OPR_ROT (rotate)\n"));
6490 case ETIR__C_OPR_SEL
:
6491 fprintf (file
, _("OPR_SEL (select)\n"));
6493 case ETIR__C_OPR_REDEF
:
6494 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6496 case ETIR__C_OPR_DFLIT
:
6497 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6500 case ETIR__C_STC_LP
:
6501 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6503 case ETIR__C_STC_LP_PSB
:
6505 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6506 /* xgettext:c-format */
6507 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6508 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6509 buf
+= 4 + 1 + buf
[4];
6510 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6512 case ETIR__C_STC_GBL
:
6513 fprintf (file
, _("STC_GBL (store cond global)\n"));
6514 /* xgettext:c-format */
6515 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6516 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6518 case ETIR__C_STC_GCA
:
6519 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6520 /* xgettext:c-format */
6521 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6522 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6524 case ETIR__C_STC_PS
:
6525 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6527 /* xgettext:c-format */
6528 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6529 (unsigned)bfd_getl32 (buf
),
6530 (unsigned)bfd_getl32 (buf
+ 4),
6531 (unsigned)bfd_getl32 (buf
+ 12),
6532 (unsigned)bfd_getl32 (buf
+ 8));
6534 case ETIR__C_STC_NOP_GBL
:
6535 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6536 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6538 case ETIR__C_STC_NOP_PS
:
6539 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6540 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6542 case ETIR__C_STC_BSR_GBL
:
6543 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6544 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6546 case ETIR__C_STC_BSR_PS
:
6547 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6548 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6550 case ETIR__C_STC_LDA_GBL
:
6551 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6552 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6554 case ETIR__C_STC_LDA_PS
:
6555 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6556 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6558 case ETIR__C_STC_BOH_GBL
:
6559 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6560 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6562 case ETIR__C_STC_BOH_PS
:
6563 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6564 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6566 case ETIR__C_STC_NBH_GBL
:
6568 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6570 case ETIR__C_STC_NBH_PS
:
6572 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6575 case ETIR__C_CTL_SETRB
:
6576 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6579 case ETIR__C_CTL_AUGRB
:
6581 unsigned int val
= bfd_getl32 (buf
);
6582 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6585 case ETIR__C_CTL_DFLOC
:
6586 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6588 case ETIR__C_CTL_STLOC
:
6589 fprintf (file
, _("CTL_STLOC (set location)\n"));
6591 case ETIR__C_CTL_STKDL
:
6592 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6595 fprintf (file
, _("*unhandled*\n"));
6603 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6605 bfd_boolean is_first
= TRUE
;
6606 bfd_boolean has_records
= FALSE
;
6610 unsigned int rec_len
;
6611 unsigned int pad_len
;
6613 unsigned int hdr_size
;
6618 unsigned char buf
[6];
6623 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6625 fprintf (file
, _("cannot read GST record length\n"));
6628 rec_len
= bfd_getl16 (buf
+ 0);
6629 if (rec_len
== bfd_getl16 (buf
+ 4)
6630 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6632 /* The format is raw: record-size, type, record-size. */
6634 pad_len
= (rec_len
+ 1) & ~1U;
6637 else if (rec_len
== EOBJ__C_EMH
)
6639 has_records
= FALSE
;
6640 pad_len
= bfd_getl16 (buf
+ 2);
6646 fprintf (file
, _("cannot find EMH in first GST record\n"));
6649 rec
= bfd_malloc (pad_len
);
6650 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6654 unsigned int rec_len2
= 0;
6655 unsigned char hdr
[4];
6659 unsigned char buf_len
[2];
6661 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6662 != sizeof (buf_len
))
6664 fprintf (file
, _("cannot read GST record length\n"));
6667 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6670 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6672 fprintf (file
, _("cannot read GST record header\n"));
6675 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6677 pad_len
= (rec_len
+ 1) & ~1U;
6680 rec
= bfd_malloc (pad_len
);
6681 memcpy (rec
, hdr
, sizeof (hdr
));
6682 hdr_size
= sizeof (hdr
);
6683 if (has_records
&& rec_len2
!= rec_len
)
6685 fprintf (file
, _(" corrupted GST\n"));
6690 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6691 != pad_len
- hdr_size
)
6693 fprintf (file
, _("cannot read GST record\n"));
6697 type
= (unsigned)bfd_getl16 (rec
);
6702 evax_bfd_print_emh (file
, rec
, rec_len
);
6705 evax_bfd_print_egsd (file
, rec
, rec_len
);
6708 evax_bfd_print_eeom (file
, rec
, rec_len
);
6713 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6716 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6719 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6722 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6730 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6731 unsigned int stride
)
6739 count
= bfd_getl32 (rel
+ 0);
6743 base
= bfd_getl32 (rel
+ 4);
6745 /* xgettext:c-format */
6746 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6750 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6756 val
= bfd_getl32 (rel
);
6759 /* xgettext:c-format */
6760 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6762 for (k
= 0; k
< 32; k
++)
6763 if (val
& (1u << k
))
6767 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6782 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6789 count
= bfd_getl32 (rel
+ 0);
6792 /* xgettext:c-format */
6793 fprintf (file
, _(" image %u (%u entries)\n"),
6794 (unsigned)bfd_getl32 (rel
+ 4), count
);
6796 for (j
= 0; j
< count
; j
++)
6798 /* xgettext:c-format */
6799 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6800 (unsigned)bfd_getl32 (rel
+ 0),
6801 (unsigned)bfd_getl32 (rel
+ 4));
6808 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6817 count
= bfd_getl32 (rel
+ 0);
6820 /* xgettext:c-format */
6821 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6822 (unsigned)bfd_getl32 (rel
+ 4), count
);
6824 for (j
= 0; j
< count
; j
++)
6828 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6843 evax_bfd_print_indent (int indent
, FILE *file
)
6845 for (; indent
; indent
--)
6850 evax_bfd_get_dsc_name (unsigned int v
)
6854 case DSC__K_DTYPE_Z
:
6855 return "Z (Unspecified)";
6856 case DSC__K_DTYPE_V
:
6858 case DSC__K_DTYPE_BU
:
6859 return "BU (Byte logical)";
6860 case DSC__K_DTYPE_WU
:
6861 return "WU (Word logical)";
6862 case DSC__K_DTYPE_LU
:
6863 return "LU (Longword logical)";
6864 case DSC__K_DTYPE_QU
:
6865 return "QU (Quadword logical)";
6866 case DSC__K_DTYPE_B
:
6867 return "B (Byte integer)";
6868 case DSC__K_DTYPE_W
:
6869 return "W (Word integer)";
6870 case DSC__K_DTYPE_L
:
6871 return "L (Longword integer)";
6872 case DSC__K_DTYPE_Q
:
6873 return "Q (Quadword integer)";
6874 case DSC__K_DTYPE_F
:
6875 return "F (Single-precision floating)";
6876 case DSC__K_DTYPE_D
:
6877 return "D (Double-precision floating)";
6878 case DSC__K_DTYPE_FC
:
6879 return "FC (Complex)";
6880 case DSC__K_DTYPE_DC
:
6881 return "DC (Double-precision Complex)";
6882 case DSC__K_DTYPE_T
:
6883 return "T (ASCII text string)";
6884 case DSC__K_DTYPE_NU
:
6885 return "NU (Numeric string, unsigned)";
6886 case DSC__K_DTYPE_NL
:
6887 return "NL (Numeric string, left separate sign)";
6888 case DSC__K_DTYPE_NLO
:
6889 return "NLO (Numeric string, left overpunched sign)";
6890 case DSC__K_DTYPE_NR
:
6891 return "NR (Numeric string, right separate sign)";
6892 case DSC__K_DTYPE_NRO
:
6893 return "NRO (Numeric string, right overpunched sig)";
6894 case DSC__K_DTYPE_NZ
:
6895 return "NZ (Numeric string, zoned sign)";
6896 case DSC__K_DTYPE_P
:
6897 return "P (Packed decimal string)";
6898 case DSC__K_DTYPE_ZI
:
6899 return "ZI (Sequence of instructions)";
6900 case DSC__K_DTYPE_ZEM
:
6901 return "ZEM (Procedure entry mask)";
6902 case DSC__K_DTYPE_DSC
:
6903 return "DSC (Descriptor, used for arrays of dyn strings)";
6904 case DSC__K_DTYPE_OU
:
6905 return "OU (Octaword logical)";
6906 case DSC__K_DTYPE_O
:
6907 return "O (Octaword integer)";
6908 case DSC__K_DTYPE_G
:
6909 return "G (Double precision G floating, 64 bit)";
6910 case DSC__K_DTYPE_H
:
6911 return "H (Quadruple precision floating, 128 bit)";
6912 case DSC__K_DTYPE_GC
:
6913 return "GC (Double precision complex, G floating)";
6914 case DSC__K_DTYPE_HC
:
6915 return "HC (Quadruple precision complex, H floating)";
6916 case DSC__K_DTYPE_CIT
:
6917 return "CIT (COBOL intermediate temporary)";
6918 case DSC__K_DTYPE_BPV
:
6919 return "BPV (Bound Procedure Value)";
6920 case DSC__K_DTYPE_BLV
:
6921 return "BLV (Bound Label Value)";
6922 case DSC__K_DTYPE_VU
:
6923 return "VU (Bit Unaligned)";
6924 case DSC__K_DTYPE_ADT
:
6925 return "ADT (Absolute Date-Time)";
6926 case DSC__K_DTYPE_VT
:
6927 return "VT (Varying Text)";
6928 case DSC__K_DTYPE_T2
:
6929 return "T2 (16-bit char)";
6930 case DSC__K_DTYPE_VT2
:
6931 return "VT2 (16-bit varying char)";
6933 return "?? (unknown)";
6938 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6940 unsigned char bclass
= buf
[3];
6941 unsigned char dtype
= buf
[2];
6942 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6943 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6945 evax_bfd_print_indent (indent
, file
);
6947 if (len
== 1 && pointer
== 0xffffffffUL
)
6950 fprintf (file
, _("64 bits *unhandled*\n"));
6954 /* xgettext:c-format */
6955 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6956 bclass
, dtype
, len
, pointer
);
6959 case DSC__K_CLASS_NCA
:
6961 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6963 const unsigned char *b
;
6965 evax_bfd_print_indent (indent
, file
);
6966 fprintf (file
, _("non-contiguous array of %s\n"),
6967 evax_bfd_get_dsc_name (dsc
->dtype
));
6968 evax_bfd_print_indent (indent
+ 1, file
);
6970 /* xgettext:c-format */
6971 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6972 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6973 evax_bfd_print_indent (indent
+ 1, file
);
6975 /* xgettext:c-format */
6976 _("arsize: %u, a0: 0x%08x\n"),
6977 (unsigned)bfd_getl32 (dsc
->arsize
),
6978 (unsigned)bfd_getl32 (dsc
->a0
));
6979 evax_bfd_print_indent (indent
+ 1, file
);
6980 fprintf (file
, _("Strides:\n"));
6981 b
= buf
+ sizeof (*dsc
);
6982 for (i
= 0; i
< dsc
->dimct
; i
++)
6984 evax_bfd_print_indent (indent
+ 2, file
);
6985 fprintf (file
, "[%u]: %u\n", i
+ 1,
6986 (unsigned)bfd_getl32 (b
));
6989 evax_bfd_print_indent (indent
+ 1, file
);
6990 fprintf (file
, _("Bounds:\n"));
6991 b
= buf
+ sizeof (*dsc
);
6992 for (i
= 0; i
< dsc
->dimct
; i
++)
6994 evax_bfd_print_indent (indent
+ 2, file
);
6995 /* xgettext:c-format */
6996 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6997 (unsigned)bfd_getl32 (b
+ 0),
6998 (unsigned)bfd_getl32 (b
+ 4));
7003 case DSC__K_CLASS_UBS
:
7005 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
7007 evax_bfd_print_indent (indent
, file
);
7008 fprintf (file
, _("unaligned bit-string of %s\n"),
7009 evax_bfd_get_dsc_name (ubs
->dtype
));
7010 evax_bfd_print_indent (indent
+ 1, file
);
7012 /* xgettext:c-format */
7013 _("base: %u, pos: %u\n"),
7014 (unsigned)bfd_getl32 (ubs
->base
),
7015 (unsigned)bfd_getl32 (ubs
->pos
));
7019 fprintf (file
, _("*unhandled*\n"));
7026 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
7028 unsigned int vflags
= buf
[0];
7029 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
7030 unsigned int len
= 5;
7032 evax_bfd_print_indent (indent
, file
);
7033 /* xgettext:c-format */
7034 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
7039 case DST__K_VFLAGS_NOVAL
:
7040 fprintf (file
, _("(no value)\n"));
7042 case DST__K_VFLAGS_NOTACTIVE
:
7043 fprintf (file
, _("(not active)\n"));
7045 case DST__K_VFLAGS_UNALLOC
:
7046 fprintf (file
, _("(not allocated)\n"));
7048 case DST__K_VFLAGS_DSC
:
7049 fprintf (file
, _("(descriptor)\n"));
7050 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
7052 case DST__K_VFLAGS_TVS
:
7053 fprintf (file
, _("(trailing value)\n"));
7055 case DST__K_VS_FOLLOWS
:
7056 fprintf (file
, _("(value spec follows)\n"));
7058 case DST__K_VFLAGS_BITOFFS
:
7059 fprintf (file
, _("(at bit offset %u)\n"), value
);
7062 /* xgettext:c-format */
7063 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
7064 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
7065 vflags
& DST__K_DISP
? 1 : 0,
7066 vflags
& DST__K_INDIR
? 1 : 0);
7067 switch (vflags
& DST__K_VALKIND_MASK
)
7069 case DST__K_VALKIND_LITERAL
:
7070 fputs (_("literal"), file
);
7072 case DST__K_VALKIND_ADDR
:
7073 fputs (_("address"), file
);
7075 case DST__K_VALKIND_DESC
:
7076 fputs (_("desc"), file
);
7078 case DST__K_VALKIND_REG
:
7079 fputs (_("reg"), file
);
7082 fputs (")\n", file
);
7089 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
7091 unsigned char kind
= buf
[2];
7092 unsigned int len
= (unsigned)bfd_getl16 (buf
);
7094 evax_bfd_print_indent (indent
, file
);
7095 /* xgettext:c-format */
7096 fprintf (file
, _("len: %2u, kind: %2u "), len
, kind
);
7100 case DST__K_TS_ATOM
:
7101 /* xgettext:c-format */
7102 fprintf (file
, _("atomic, type=0x%02x %s\n"),
7103 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
7106 fprintf (file
, _("indirect, defined at 0x%08x\n"),
7107 (unsigned)bfd_getl32 (buf
));
7109 case DST__K_TS_TPTR
:
7110 fprintf (file
, _("typed pointer\n"));
7111 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
7114 fprintf (file
, _("pointer\n"));
7116 case DST__K_TS_ARRAY
:
7118 const unsigned char *vs
;
7119 unsigned int vec_len
;
7122 fprintf (file
, _("array, dim: %u, bitmap: "), buf
[0]);
7123 vec_len
= (buf
[0] + 1 + 7) / 8;
7124 for (i
= 0; i
< vec_len
; i
++)
7125 fprintf (file
, " %02x", buf
[i
+ 1]);
7127 vs
= buf
+ 1 + vec_len
;
7128 evax_bfd_print_indent (indent
, file
);
7129 fprintf (file
, _("array descriptor:\n"));
7130 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
7131 for (i
= 0; i
< buf
[0] + 1U; i
++)
7132 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
7134 evax_bfd_print_indent (indent
, file
);
7136 fprintf (file
, _("type spec for element:\n"));
7138 fprintf (file
, _("type spec for subscript %u:\n"), i
);
7139 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
7140 vs
+= bfd_getl16 (vs
);
7145 fprintf (file
, _("*unhandled*\n"));
7150 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
7152 unsigned int off
= 0;
7153 unsigned int pc
= 0;
7154 unsigned int line
= 0;
7156 fprintf (file
, _("Debug symbol table:\n"));
7158 while (dst_size
> 0)
7160 struct vms_dst_header dsth
;
7165 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
7167 fprintf (file
, _("cannot read DST header\n"));
7170 len
= bfd_getl16 (dsth
.length
);
7171 type
= bfd_getl16 (dsth
.type
);
7172 /* xgettext:c-format */
7173 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
7183 len
-= sizeof (dsth
);
7184 buf
= _bfd_malloc_and_read (abfd
, len
, len
);
7187 fprintf (file
, _("cannot read DST symbol\n"));
7192 case DSC__K_DTYPE_V
:
7193 case DSC__K_DTYPE_BU
:
7194 case DSC__K_DTYPE_WU
:
7195 case DSC__K_DTYPE_LU
:
7196 case DSC__K_DTYPE_QU
:
7197 case DSC__K_DTYPE_B
:
7198 case DSC__K_DTYPE_W
:
7199 case DSC__K_DTYPE_L
:
7200 case DSC__K_DTYPE_Q
:
7201 case DSC__K_DTYPE_F
:
7202 case DSC__K_DTYPE_D
:
7203 case DSC__K_DTYPE_FC
:
7204 case DSC__K_DTYPE_DC
:
7205 case DSC__K_DTYPE_T
:
7206 case DSC__K_DTYPE_NU
:
7207 case DSC__K_DTYPE_NL
:
7208 case DSC__K_DTYPE_NLO
:
7209 case DSC__K_DTYPE_NR
:
7210 case DSC__K_DTYPE_NRO
:
7211 case DSC__K_DTYPE_NZ
:
7212 case DSC__K_DTYPE_P
:
7213 case DSC__K_DTYPE_ZI
:
7214 case DSC__K_DTYPE_ZEM
:
7215 case DSC__K_DTYPE_DSC
:
7216 case DSC__K_DTYPE_OU
:
7217 case DSC__K_DTYPE_O
:
7218 case DSC__K_DTYPE_G
:
7219 case DSC__K_DTYPE_H
:
7220 case DSC__K_DTYPE_GC
:
7221 case DSC__K_DTYPE_HC
:
7222 case DSC__K_DTYPE_CIT
:
7223 case DSC__K_DTYPE_BPV
:
7224 case DSC__K_DTYPE_BLV
:
7225 case DSC__K_DTYPE_VU
:
7226 case DSC__K_DTYPE_ADT
:
7227 case DSC__K_DTYPE_VT
:
7228 case DSC__K_DTYPE_T2
:
7229 case DSC__K_DTYPE_VT2
:
7230 fprintf (file
, _("standard data: %s\n"),
7231 evax_bfd_get_dsc_name (type
));
7232 evax_bfd_print_valspec (buf
, 4, file
);
7233 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
7237 struct vms_dst_modbeg
*dst
= (void *)buf
;
7238 const char *name
= (const char *)buf
+ sizeof (*dst
);
7240 fprintf (file
, _("modbeg\n"));
7241 /* xgettext:c-format */
7242 fprintf (file
, _(" flags: %d, language: %u, "
7243 "major: %u, minor: %u\n"),
7245 (unsigned)bfd_getl32 (dst
->language
),
7246 (unsigned)bfd_getl16 (dst
->major
),
7247 (unsigned)bfd_getl16 (dst
->minor
));
7248 fprintf (file
, _(" module name: %.*s\n"),
7250 name
+= name
[0] + 1;
7251 fprintf (file
, _(" compiler : %.*s\n"),
7256 fprintf (file
, _("modend\n"));
7260 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
7261 const char *name
= (const char *)buf
+ sizeof (*dst
);
7263 fputs (_("rtnbeg\n"), file
);
7264 /* xgettext:c-format */
7265 fprintf (file
, _(" flags: %u, address: 0x%08x, "
7266 "pd-address: 0x%08x\n"),
7268 (unsigned)bfd_getl32 (dst
->address
),
7269 (unsigned)bfd_getl32 (dst
->pd_address
));
7270 fprintf (file
, _(" routine name: %.*s\n"),
7276 struct vms_dst_rtnend
*dst
= (void *)buf
;
7278 fprintf (file
, _("rtnend: size 0x%08x\n"),
7279 (unsigned)bfd_getl32 (dst
->size
));
7284 struct vms_dst_prolog
*dst
= (void *)buf
;
7286 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
7287 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
7292 struct vms_dst_epilog
*dst
= (void *)buf
;
7294 /* xgettext:c-format */
7295 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
7296 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
7301 struct vms_dst_blkbeg
*dst
= (void *)buf
;
7302 const char *name
= (const char *)buf
+ sizeof (*dst
);
7304 /* xgettext:c-format */
7305 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
7306 (unsigned)bfd_getl32 (dst
->address
),
7312 struct vms_dst_blkend
*dst
= (void *)buf
;
7314 fprintf (file
, _("blkend: size: 0x%08x\n"),
7315 (unsigned)bfd_getl32 (dst
->size
));
7318 case DST__K_TYPSPEC
:
7320 fprintf (file
, _("typspec (len: %u)\n"), len
);
7321 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7322 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7327 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7328 evax_bfd_print_valspec (buf
, 4, file
);
7333 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7334 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7336 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7337 evax_bfd_print_valspec (buf
, 4, file
);
7338 fprintf (file
, _(" len: %u bits\n"),
7339 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7343 fprintf (file
, _("recend\n"));
7345 case DST__K_ENUMBEG
:
7346 /* xgettext:c-format */
7347 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7348 buf
[0], buf
[1], buf
+ 2);
7350 case DST__K_ENUMELT
:
7351 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7352 evax_bfd_print_valspec (buf
, 4, file
);
7354 case DST__K_ENUMEND
:
7355 fprintf (file
, _("enumend\n"));
7359 struct vms_dst_label
*lab
= (void *)buf
;
7360 fprintf (file
, _("label, name: %.*s\n"),
7361 lab
->name
[0], lab
->name
+ 1);
7362 fprintf (file
, _(" address: 0x%08x\n"),
7363 (unsigned)bfd_getl32 (lab
->value
));
7366 case DST__K_DIS_RANGE
:
7368 unsigned int cnt
= bfd_getl32 (buf
);
7369 unsigned char *rng
= buf
+ 4;
7372 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7373 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7374 /* xgettext:c-format */
7375 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7376 (unsigned)bfd_getl32 (rng
),
7377 (unsigned)bfd_getl32 (rng
+ 4));
7381 case DST__K_LINE_NUM
:
7383 unsigned char *buf_orig
= buf
;
7385 fprintf (file
, _("line num (len: %u)\n"), len
);
7390 unsigned char cmdlen
;
7400 case DST__K_DELTA_PC_W
:
7401 val
= bfd_getl16 (buf
+ 1);
7402 fprintf (file
, _("delta_pc_w %u\n"), val
);
7407 case DST__K_INCR_LINUM
:
7409 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7413 case DST__K_INCR_LINUM_W
:
7414 val
= bfd_getl16 (buf
+ 1);
7415 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7419 case DST__K_INCR_LINUM_L
:
7420 val
= bfd_getl32 (buf
+ 1);
7421 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7425 case DST__K_SET_LINUM
:
7426 line
= bfd_getl16 (buf
+ 1);
7427 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7430 case DST__K_SET_LINUM_B
:
7432 fprintf (file
, _("set_line_num_b %u\n"), line
);
7435 case DST__K_SET_LINUM_L
:
7436 line
= bfd_getl32 (buf
+ 1);
7437 fprintf (file
, _("set_line_num_l %u\n"), line
);
7440 case DST__K_SET_ABS_PC
:
7441 pc
= bfd_getl32 (buf
+ 1);
7442 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7445 case DST__K_DELTA_PC_L
:
7446 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7447 (unsigned)bfd_getl32 (buf
+ 1));
7451 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7453 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7457 val
= bfd_getl16 (buf
+ 1);
7458 fprintf (file
, _("term_w: 0x%04x"), val
);
7460 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7466 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7467 line
++; /* FIXME: curr increment. */
7469 /* xgettext:c-format */
7470 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7475 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7488 unsigned char *buf_orig
= buf
;
7490 fprintf (file
, _("source (len: %u)\n"), len
);
7494 signed char cmd
= buf
[0];
7495 unsigned char cmdlen
= 0;
7499 case DST__K_SRC_DECLFILE
:
7501 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7504 /* xgettext:c-format */
7505 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7507 src
->length
, src
->flags
,
7508 (unsigned)bfd_getl16 (src
->fileid
));
7509 /* xgettext:c-format */
7510 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7511 "ebk: 0x%08x, ffb: 0x%04x, "
7513 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7514 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7515 (unsigned)bfd_getl32 (src
->rms_ebk
),
7516 (unsigned)bfd_getl16 (src
->rms_ffb
),
7518 name
= (const char *)buf
+ 1 + sizeof (*src
);
7519 fprintf (file
, _(" filename : %.*s\n"),
7521 name
+= name
[0] + 1;
7522 fprintf (file
, _(" module name: %.*s\n"),
7524 cmdlen
= 2 + src
->length
;
7527 case DST__K_SRC_SETFILE
:
7528 fprintf (file
, _(" setfile %u\n"),
7529 (unsigned)bfd_getl16 (buf
+ 1));
7532 case DST__K_SRC_SETREC_W
:
7533 fprintf (file
, _(" setrec %u\n"),
7534 (unsigned)bfd_getl16 (buf
+ 1));
7537 case DST__K_SRC_SETREC_L
:
7538 fprintf (file
, _(" setrec %u\n"),
7539 (unsigned)bfd_getl32 (buf
+ 1));
7542 case DST__K_SRC_SETLNUM_W
:
7543 fprintf (file
, _(" setlnum %u\n"),
7544 (unsigned)bfd_getl16 (buf
+ 1));
7547 case DST__K_SRC_SETLNUM_L
:
7548 fprintf (file
, _(" setlnum %u\n"),
7549 (unsigned)bfd_getl32 (buf
+ 1));
7552 case DST__K_SRC_DEFLINES_W
:
7553 fprintf (file
, _(" deflines %u\n"),
7554 (unsigned)bfd_getl16 (buf
+ 1));
7557 case DST__K_SRC_DEFLINES_B
:
7558 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7561 case DST__K_SRC_FORMFEED
:
7562 fprintf (file
, _(" formfeed\n"));
7566 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7578 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7586 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7588 struct vms_eihd eihd
;
7591 unsigned int eiha_off
;
7592 unsigned int eihi_off
;
7593 unsigned int eihs_off
;
7594 unsigned int eisd_off
;
7595 unsigned int eihef_off
= 0;
7596 unsigned int eihnp_off
= 0;
7597 unsigned int dmt_vbn
= 0;
7598 unsigned int dmt_size
= 0;
7599 unsigned int dst_vbn
= 0;
7600 unsigned int dst_size
= 0;
7601 unsigned int gst_vbn
= 0;
7602 unsigned int gst_size
= 0;
7603 unsigned int eiaf_vbn
= 0;
7604 unsigned int eiaf_size
= 0;
7605 unsigned int eihvn_off
;
7607 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7608 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7610 fprintf (file
, _("cannot read EIHD\n"));
7613 /* xgettext:c-format */
7614 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7615 (unsigned)bfd_getl32 (eihd
.size
),
7616 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7617 /* xgettext:c-format */
7618 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7619 (unsigned)bfd_getl32 (eihd
.majorid
),
7620 (unsigned)bfd_getl32 (eihd
.minorid
));
7622 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7626 name
= _("executable");
7629 name
= _("linkable image");
7632 name
= _("unknown");
7635 /* xgettext:c-format */
7636 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7638 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7641 case EIHD__C_NATIVE
:
7648 name
= _("unknown");
7651 /* xgettext:c-format */
7652 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7654 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7655 eiha_off
= bfd_getl32 (eihd
.activoff
);
7656 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7657 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7658 /* xgettext:c-format */
7659 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7660 "imgid: %u, patch: %u\n"),
7661 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7662 (unsigned)bfd_getl32 (eihd
.patchoff
));
7663 fprintf (file
, _(" fixup info rva: "));
7664 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7665 fprintf (file
, _(", symbol vector rva: "));
7666 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7667 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7668 fprintf (file
, _("\n"
7669 " version array off: %u\n"),
7672 /* xgettext:c-format */
7673 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7674 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7675 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7676 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7677 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7678 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7679 fprintf (file
, _(" linker flags: %08x:"), val
);
7680 if (val
& EIHD__M_LNKDEBUG
)
7681 fprintf (file
, " LNKDEBUG");
7682 if (val
& EIHD__M_LNKNOTFR
)
7683 fprintf (file
, " LNKNOTFR");
7684 if (val
& EIHD__M_NOP0BUFS
)
7685 fprintf (file
, " NOP0BUFS");
7686 if (val
& EIHD__M_PICIMG
)
7687 fprintf (file
, " PICIMG");
7688 if (val
& EIHD__M_P0IMAGE
)
7689 fprintf (file
, " P0IMAGE");
7690 if (val
& EIHD__M_DBGDMT
)
7691 fprintf (file
, " DBGDMT");
7692 if (val
& EIHD__M_INISHR
)
7693 fprintf (file
, " INISHR");
7694 if (val
& EIHD__M_XLATED
)
7695 fprintf (file
, " XLATED");
7696 if (val
& EIHD__M_BIND_CODE_SEC
)
7697 fprintf (file
, " BIND_CODE_SEC");
7698 if (val
& EIHD__M_BIND_DATA_SEC
)
7699 fprintf (file
, " BIND_DATA_SEC");
7700 if (val
& EIHD__M_MKTHREADS
)
7701 fprintf (file
, " MKTHREADS");
7702 if (val
& EIHD__M_UPCALLS
)
7703 fprintf (file
, " UPCALLS");
7704 if (val
& EIHD__M_OMV_READY
)
7705 fprintf (file
, " OMV_READY");
7706 if (val
& EIHD__M_EXT_BIND_SECT
)
7707 fprintf (file
, " EXT_BIND_SECT");
7708 fprintf (file
, "\n");
7709 /* xgettext:c-format */
7710 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7711 "match ctrl: %u, symvect_size: %u\n"),
7712 (unsigned)bfd_getl32 (eihd
.ident
),
7713 (unsigned)bfd_getl32 (eihd
.sysver
),
7715 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7716 fprintf (file
, _(" BPAGE: %u"),
7717 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7718 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7720 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7721 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7722 /* xgettext:c-format */
7723 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7724 eihef_off
, eihnp_off
);
7726 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7730 struct vms_eihvn eihvn
;
7734 fprintf (file
, _("system version array information:\n"));
7735 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7736 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7738 fprintf (file
, _("cannot read EIHVN header\n"));
7741 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7742 for (j
= 0; j
< 32; j
++)
7743 if (mask
& (1 << j
))
7745 struct vms_eihvn_subversion ver
;
7746 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7748 fprintf (file
, _("cannot read EIHVN version\n"));
7751 fprintf (file
, _(" %02u "), j
);
7754 case EIHVN__BASE_IMAGE_BIT
:
7755 fputs (_("BASE_IMAGE "), file
);
7757 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7758 fputs (_("MEMORY_MANAGEMENT"), file
);
7761 fputs (_("IO "), file
);
7763 case EIHVN__FILES_VOLUMES_BIT
:
7764 fputs (_("FILES_VOLUMES "), file
);
7766 case EIHVN__PROCESS_SCHED_BIT
:
7767 fputs (_("PROCESS_SCHED "), file
);
7769 case EIHVN__SYSGEN_BIT
:
7770 fputs (_("SYSGEN "), file
);
7772 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7773 fputs (_("CLUSTERS_LOCKMGR "), file
);
7775 case EIHVN__LOGICAL_NAMES_BIT
:
7776 fputs (_("LOGICAL_NAMES "), file
);
7778 case EIHVN__SECURITY_BIT
:
7779 fputs (_("SECURITY "), file
);
7781 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7782 fputs (_("IMAGE_ACTIVATOR "), file
);
7784 case EIHVN__NETWORKS_BIT
:
7785 fputs (_("NETWORKS "), file
);
7787 case EIHVN__COUNTERS_BIT
:
7788 fputs (_("COUNTERS "), file
);
7790 case EIHVN__STABLE_BIT
:
7791 fputs (_("STABLE "), file
);
7793 case EIHVN__MISC_BIT
:
7794 fputs (_("MISC "), file
);
7796 case EIHVN__CPU_BIT
:
7797 fputs (_("CPU "), file
);
7799 case EIHVN__VOLATILE_BIT
:
7800 fputs (_("VOLATILE "), file
);
7802 case EIHVN__SHELL_BIT
:
7803 fputs (_("SHELL "), file
);
7805 case EIHVN__POSIX_BIT
:
7806 fputs (_("POSIX "), file
);
7808 case EIHVN__MULTI_PROCESSING_BIT
:
7809 fputs (_("MULTI_PROCESSING "), file
);
7811 case EIHVN__GALAXY_BIT
:
7812 fputs (_("GALAXY "), file
);
7815 fputs (_("*unknown* "), file
);
7818 fprintf (file
, ": %u.%u\n",
7819 (unsigned)bfd_getl16 (ver
.major
),
7820 (unsigned)bfd_getl16 (ver
.minor
));
7826 struct vms_eiha eiha
;
7828 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7829 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7831 fprintf (file
, _("cannot read EIHA\n"));
7834 fprintf (file
, _("Image activation: (size=%u)\n"),
7835 (unsigned)bfd_getl32 (eiha
.size
));
7836 /* xgettext:c-format */
7837 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7838 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7839 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7840 /* xgettext:c-format */
7841 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7842 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7843 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7844 /* xgettext:c-format */
7845 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7846 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7847 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7848 /* xgettext:c-format */
7849 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7850 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7851 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7852 /* xgettext:c-format */
7853 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7854 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7855 (unsigned)bfd_getl32 (eiha
.inishr
));
7859 struct vms_eihi eihi
;
7861 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7862 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7864 fprintf (file
, _("cannot read EIHI\n"));
7867 /* xgettext:c-format */
7868 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7869 (unsigned)bfd_getl32 (eihi
.majorid
),
7870 (unsigned)bfd_getl32 (eihi
.minorid
));
7871 fprintf (file
, _(" image name : %.*s\n"),
7872 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7873 fprintf (file
, _(" link time : %s\n"),
7874 vms_time_to_str (eihi
.linktime
));
7875 fprintf (file
, _(" image ident : %.*s\n"),
7876 eihi
.imgid
[0], eihi
.imgid
+ 1);
7877 fprintf (file
, _(" linker ident : %.*s\n"),
7878 eihi
.linkid
[0], eihi
.linkid
+ 1);
7879 fprintf (file
, _(" image build ident: %.*s\n"),
7880 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7884 struct vms_eihs eihs
;
7886 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7887 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7889 fprintf (file
, _("cannot read EIHS\n"));
7892 /* xgettext:c-format */
7893 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7894 (unsigned)bfd_getl32 (eihs
.majorid
),
7895 (unsigned)bfd_getl32 (eihs
.minorid
));
7896 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7897 dst_size
= bfd_getl32 (eihs
.dstsize
);
7898 /* xgettext:c-format */
7899 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7900 dst_vbn
, dst_size
, dst_size
);
7901 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7902 gst_size
= bfd_getl32 (eihs
.gstsize
);
7903 /* xgettext:c-format */
7904 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7906 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7907 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7908 /* xgettext:c-format */
7909 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7912 while (eisd_off
!= 0)
7914 struct vms_eisd eisd
;
7919 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7920 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7922 fprintf (file
, _("cannot read EISD\n"));
7925 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7926 if (len
!= (unsigned)-1)
7930 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7932 /* xgettext:c-format */
7933 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7934 "size: %u, offset: %u)\n"),
7935 (unsigned)bfd_getl32 (eisd
.majorid
),
7936 (unsigned)bfd_getl32 (eisd
.minorid
),
7940 /* xgettext:c-format */
7941 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7942 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7943 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7944 (unsigned)bfd_getl32 (eisd
.secsize
));
7945 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7946 fprintf (file
, _(" flags: 0x%04x"), val
);
7947 if (val
& EISD__M_GBL
)
7948 fprintf (file
, " GBL");
7949 if (val
& EISD__M_CRF
)
7950 fprintf (file
, " CRF");
7951 if (val
& EISD__M_DZRO
)
7952 fprintf (file
, " DZRO");
7953 if (val
& EISD__M_WRT
)
7954 fprintf (file
, " WRT");
7955 if (val
& EISD__M_INITALCODE
)
7956 fprintf (file
, " INITALCODE");
7957 if (val
& EISD__M_BASED
)
7958 fprintf (file
, " BASED");
7959 if (val
& EISD__M_FIXUPVEC
)
7960 fprintf (file
, " FIXUPVEC");
7961 if (val
& EISD__M_RESIDENT
)
7962 fprintf (file
, " RESIDENT");
7963 if (val
& EISD__M_VECTOR
)
7964 fprintf (file
, " VECTOR");
7965 if (val
& EISD__M_PROTECT
)
7966 fprintf (file
, " PROTECT");
7967 if (val
& EISD__M_LASTCLU
)
7968 fprintf (file
, " LASTCLU");
7969 if (val
& EISD__M_EXE
)
7970 fprintf (file
, " EXE");
7971 if (val
& EISD__M_NONSHRADR
)
7972 fprintf (file
, " NONSHRADR");
7973 if (val
& EISD__M_QUAD_LENGTH
)
7974 fprintf (file
, " QUAD_LENGTH");
7975 if (val
& EISD__M_ALLOC_64BIT
)
7976 fprintf (file
, " ALLOC_64BIT");
7977 fprintf (file
, "\n");
7978 if (val
& EISD__M_FIXUPVEC
)
7980 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7981 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7983 /* xgettext:c-format */
7984 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7985 (unsigned)bfd_getl32 (eisd
.vbn
),
7986 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7989 case EISD__K_NORMAL
:
7990 fputs (_("NORMAL"), file
);
7992 case EISD__K_SHRFXD
:
7993 fputs (_("SHRFXD"), file
);
7995 case EISD__K_PRVFXD
:
7996 fputs (_("PRVFXD"), file
);
7998 case EISD__K_SHRPIC
:
7999 fputs (_("SHRPIC"), file
);
8001 case EISD__K_PRVPIC
:
8002 fputs (_("PRVPIC"), file
);
8004 case EISD__K_USRSTACK
:
8005 fputs (_("USRSTACK"), file
);
8008 fputs (_("*unknown*"), file
);
8011 fputs (_(")\n"), file
);
8012 if (val
& EISD__M_GBL
)
8013 /* xgettext:c-format */
8014 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
8015 (unsigned)bfd_getl32 (eisd
.ident
),
8016 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
8022 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8024 fprintf (file
, _("cannot read DMT\n"));
8028 fprintf (file
, _("Debug module table:\n"));
8030 while (dmt_size
> 0)
8032 struct vms_dmt_header dmth
;
8035 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
8037 fprintf (file
, _("cannot read DMT header\n"));
8040 count
= bfd_getl16 (dmth
.psect_count
);
8042 /* xgettext:c-format */
8043 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
8044 (unsigned)bfd_getl32 (dmth
.modbeg
),
8045 (unsigned)bfd_getl32 (dmth
.size
), count
);
8046 dmt_size
-= sizeof (dmth
);
8049 struct vms_dmt_psect dmtp
;
8051 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
8053 fprintf (file
, _("cannot read DMT psect\n"));
8056 /* xgettext:c-format */
8057 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
8058 (unsigned)bfd_getl32 (dmtp
.start
),
8059 (unsigned)bfd_getl32 (dmtp
.length
));
8061 dmt_size
-= sizeof (dmtp
);
8068 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8070 fprintf (file
, _("cannot read DST\n"));
8074 evax_bfd_print_dst (abfd
, dst_size
, file
);
8078 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
8080 fprintf (file
, _("cannot read GST\n"));
8084 fprintf (file
, _("Global symbol table:\n"));
8085 evax_bfd_print_eobj (abfd
, file
);
8090 struct vms_eiaf
*eiaf
;
8091 unsigned int qrelfixoff
;
8092 unsigned int lrelfixoff
;
8093 unsigned int qdotadroff
;
8094 unsigned int ldotadroff
;
8095 unsigned int shrimgcnt
;
8096 unsigned int shlstoff
;
8097 unsigned int codeadroff
;
8098 unsigned int lpfixoff
;
8099 unsigned int chgprtoff
;
8100 file_ptr f_off
= (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
;
8102 if (bfd_seek (abfd
, f_off
, SEEK_SET
) != 0
8103 || (buf
= _bfd_malloc_and_read (abfd
, eiaf_size
, eiaf_size
)) == NULL
)
8105 fprintf (file
, _("cannot read EIHA\n"));
8108 eiaf
= (struct vms_eiaf
*)buf
;
8110 /* xgettext:c-format */
8111 _("Image activator fixup: (major: %u, minor: %u)\n"),
8112 (unsigned)bfd_getl32 (eiaf
->majorid
),
8113 (unsigned)bfd_getl32 (eiaf
->minorid
));
8114 /* xgettext:c-format */
8115 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
8116 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
8117 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
8118 /* xgettext:c-format */
8119 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
8120 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
8121 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
8122 fprintf (file
, _(" size : %u\n"),
8123 (unsigned)bfd_getl32 (eiaf
->size
));
8124 fprintf (file
, _(" flags: 0x%08x\n"),
8125 (unsigned)bfd_getl32 (eiaf
->flags
));
8126 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
8127 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
8128 /* xgettext:c-format */
8129 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
8130 qrelfixoff
, lrelfixoff
);
8131 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
8132 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
8133 /* xgettext:c-format */
8134 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
8135 qdotadroff
, ldotadroff
);
8136 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
8137 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
8138 /* xgettext:c-format */
8139 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
8140 codeadroff
, lpfixoff
);
8141 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
8142 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
8143 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
8144 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
8145 /* xgettext:c-format */
8146 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
8147 shlstoff
, shrimgcnt
);
8148 /* xgettext:c-format */
8149 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
8150 (unsigned)bfd_getl32 (eiaf
->shlextra
),
8151 (unsigned)bfd_getl32 (eiaf
->permctx
));
8152 fprintf (file
, _(" base_va : 0x%08x\n"),
8153 (unsigned)bfd_getl32 (eiaf
->base_va
));
8154 fprintf (file
, _(" lppsbfixoff: %5u\n"),
8155 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
8159 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
8162 fprintf (file
, _(" Shareable images:\n"));
8163 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
8166 /* xgettext:c-format */
8167 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
8168 j
, shl
->size
, shl
->flags
,
8169 shl
->imgnam
[0], shl
->imgnam
+ 1);
8172 if (qrelfixoff
!= 0)
8174 fprintf (file
, _(" quad-word relocation fixups:\n"));
8175 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
8177 if (lrelfixoff
!= 0)
8179 fprintf (file
, _(" long-word relocation fixups:\n"));
8180 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
8182 if (qdotadroff
!= 0)
8184 fprintf (file
, _(" quad-word .address reference fixups:\n"));
8185 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
8187 if (ldotadroff
!= 0)
8189 fprintf (file
, _(" long-word .address reference fixups:\n"));
8190 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
8192 if (codeadroff
!= 0)
8194 fprintf (file
, _(" Code Address Reference Fixups:\n"));
8195 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
8199 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
8200 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
8204 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
8205 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
8208 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
8209 for (j
= 0; j
< count
; j
++, eicp
++)
8211 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
8213 /* xgettext:c-format */
8214 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
8215 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
8216 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
8217 (unsigned)bfd_getl32 (eicp
->size
),
8218 (unsigned)bfd_getl32 (eicp
->newprt
));
8222 fprintf (file
, "NA");
8224 case PRT__C_RESERVED
:
8225 fprintf (file
, "RES");
8228 fprintf (file
, "KW");
8231 fprintf (file
, "KR");
8234 fprintf (file
, "UW");
8237 fprintf (file
, "EW");
8240 fprintf (file
, "ERKW");
8243 fprintf (file
, "ER");
8246 fprintf (file
, "SW");
8249 fprintf (file
, "SREW");
8252 fprintf (file
, "SRKW");
8255 fprintf (file
, "SR");
8258 fprintf (file
, "URSW");
8261 fprintf (file
, "UREW");
8264 fprintf (file
, "URKW");
8267 fprintf (file
, "UR");
8281 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
8283 FILE *file
= (FILE *)ptr
;
8285 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8286 evax_bfd_print_image (abfd
, file
);
8289 if (bfd_seek (abfd
, 0, SEEK_SET
))
8291 evax_bfd_print_eobj (abfd
, file
);
8298 /* Slurp ETIR/EDBG/ETBT VMS object records. */
8301 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
8303 asection
*cur_section
;
8304 file_ptr cur_offset
;
8305 asection
*dst_section
;
8306 file_ptr dst_offset
;
8308 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
8314 dst_section
= PRIV (dst_section
);
8318 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
8320 /* Discard the DST section. */
8324 else if (dst_section
)
8326 dst_offset
= dst_section
->output_offset
;
8327 dst_section
= dst_section
->output_section
;
8336 type
= _bfd_vms_get_object_record (abfd
);
8339 vms_debug2 ((2, "next_record failed\n"));
8345 PRIV (image_section
) = cur_section
;
8346 PRIV (image_offset
) = cur_offset
;
8347 res
= _bfd_vms_slurp_etir (abfd
, info
);
8348 cur_section
= PRIV (image_section
);
8349 cur_offset
= PRIV (image_offset
);
8353 if (dst_section
== NULL
)
8355 PRIV (image_section
) = dst_section
;
8356 PRIV (image_offset
) = dst_offset
;
8357 res
= _bfd_vms_slurp_etir (abfd
, info
);
8358 dst_offset
= PRIV (image_offset
);
8367 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8374 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8375 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8380 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8383 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8385 struct alpha_vms_shlib_el
*sl
;
8386 asection
*sect
= PRIV2 (src
, image_section
);
8387 file_ptr offset
= PRIV2 (src
, image_offset
);
8390 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8391 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8392 sl
->has_fixups
= TRUE
;
8393 p
= VEC_APPEND (sl
->lp
, bfd_vma
);
8396 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8397 sect
->output_section
->flags
|= SEC_RELOC
;
8401 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8404 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8406 struct alpha_vms_shlib_el
*sl
;
8407 asection
*sect
= PRIV2 (src
, image_section
);
8408 file_ptr offset
= PRIV2 (src
, image_offset
);
8411 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8412 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8413 sl
->has_fixups
= TRUE
;
8414 p
= VEC_APPEND (sl
->ca
, bfd_vma
);
8417 *p
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8418 sect
->output_section
->flags
|= SEC_RELOC
;
8422 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8425 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8426 bfd
*shlib
, bfd_vma vec
)
8428 struct alpha_vms_shlib_el
*sl
;
8429 struct alpha_vms_vma_ref
*r
;
8430 asection
*sect
= PRIV2 (src
, image_section
);
8431 file_ptr offset
= PRIV2 (src
, image_offset
);
8433 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8434 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8435 sl
->has_fixups
= TRUE
;
8436 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8439 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8441 sect
->output_section
->flags
|= SEC_RELOC
;
8446 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8447 unsigned int shr ATTRIBUTE_UNUSED
,
8448 bfd_vma vec ATTRIBUTE_UNUSED
)
8450 /* Not yet supported. */
8454 /* Add relocation. FIXME: Not yet emitted. */
8457 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8463 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8468 static struct bfd_hash_entry
*
8469 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8470 struct bfd_hash_table
*table
,
8473 struct alpha_vms_link_hash_entry
*ret
=
8474 (struct alpha_vms_link_hash_entry
*) entry
;
8476 /* Allocate the structure if it has not already been allocated by a
8479 ret
= ((struct alpha_vms_link_hash_entry
*)
8480 bfd_hash_allocate (table
,
8481 sizeof (struct alpha_vms_link_hash_entry
)));
8485 /* Call the allocation method of the superclass. */
8486 ret
= ((struct alpha_vms_link_hash_entry
*)
8487 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8492 return (struct bfd_hash_entry
*) ret
;
8496 alpha_vms_bfd_link_hash_table_free (bfd
*abfd
)
8498 struct alpha_vms_link_hash_table
*t
;
8501 t
= (struct alpha_vms_link_hash_table
*) abfd
->link
.hash
;
8502 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8504 struct alpha_vms_shlib_el
*shlib
;
8506 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8507 free (&VEC_EL (shlib
->ca
, bfd_vma
, 0));
8508 free (&VEC_EL (shlib
->lp
, bfd_vma
, 0));
8509 free (&VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, 0));
8511 free (&VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, 0));
8513 _bfd_generic_link_hash_table_free (abfd
);
8516 /* Create an Alpha/VMS link hash table. */
8518 static struct bfd_link_hash_table
*
8519 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8521 struct alpha_vms_link_hash_table
*ret
;
8522 size_t amt
= sizeof (struct alpha_vms_link_hash_table
);
8524 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8527 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8528 alpha_vms_link_hash_newfunc
,
8529 sizeof (struct alpha_vms_link_hash_entry
)))
8535 VEC_INIT (ret
->shrlibs
);
8537 ret
->root
.hash_table_free
= alpha_vms_bfd_link_hash_table_free
;
8543 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8547 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8549 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8550 struct alpha_vms_link_hash_entry
*h
;
8551 struct bfd_link_hash_entry
*h_root
;
8554 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8557 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8559 /* In selective_search mode, only add definition that are
8561 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8562 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8563 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8569 h_root
= (struct bfd_link_hash_entry
*) h
;
8570 if (!_bfd_generic_link_add_one_symbol (info
, abfd
, sym
.name
, sym
.flags
,
8571 sym
.section
, sym
.value
, NULL
,
8572 FALSE
, FALSE
, &h_root
))
8574 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8576 if ((e
->flags
& EGSY__V_DEF
)
8578 && abfd
->xvec
== info
->output_bfd
->xvec
)
8582 if (abfd
->flags
& DYNAMIC
)
8584 struct alpha_vms_shlib_el
*shlib
;
8586 /* We do not want to include any of the sections in a dynamic
8587 object in the output file. See comment in elflink.c. */
8588 bfd_section_list_clear (abfd
);
8590 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8591 struct alpha_vms_shlib_el
);
8595 VEC_INIT (shlib
->ca
);
8596 VEC_INIT (shlib
->lp
);
8597 VEC_INIT (shlib
->qr
);
8598 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8605 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8608 struct bfd_link_hash_entry
**pundef
;
8609 struct bfd_link_hash_entry
**next_pundef
;
8611 /* We only accept VMS libraries. */
8612 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8614 bfd_set_error (bfd_error_wrong_format
);
8618 /* The archive_pass field in the archive itself is used to
8619 initialize PASS, since we may search the same archive multiple
8621 pass
= ++abfd
->archive_pass
;
8623 /* Look through the list of undefined symbols. */
8624 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8626 struct bfd_link_hash_entry
*h
;
8632 next_pundef
= &(*pundef
)->u
.undef
.next
;
8634 /* When a symbol is defined, it is not necessarily removed from
8636 if (h
->type
!= bfd_link_hash_undefined
8637 && h
->type
!= bfd_link_hash_common
)
8639 /* Remove this entry from the list, for general cleanliness
8640 and because we are going to look through the list again
8641 if we search any more libraries. We can't remove the
8642 entry if it is the tail, because that would lose any
8643 entries we add to the list later on. */
8644 if (*pundef
!= info
->hash
->undefs_tail
)
8646 *pundef
= *next_pundef
;
8647 next_pundef
= pundef
;
8652 /* Look for this symbol in the archive hash table. */
8653 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8654 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8656 /* Nothing in this slot. */
8660 element
= bfd_get_elt_at_index (abfd
, symidx
);
8661 if (element
== NULL
)
8664 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8666 /* Next symbol if this archive is wrong or already handled. */
8670 if (! bfd_check_format (element
, bfd_object
))
8672 element
->archive_pass
= -1;
8676 orig_element
= element
;
8677 if (bfd_is_thin_archive (abfd
))
8679 element
= _bfd_vms_lib_get_imagelib_file (element
);
8680 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8682 orig_element
->archive_pass
= -1;
8687 /* Unlike the generic linker, we know that this element provides
8688 a definition for an undefined symbol and we know that we want
8689 to include it. We don't need to check anything. */
8690 if (!(*info
->callbacks
8691 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8693 if (!alpha_vms_link_add_object_symbols (element
, info
))
8696 orig_element
->archive_pass
= pass
;
8703 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8705 switch (bfd_get_format (abfd
))
8708 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8710 return alpha_vms_link_add_object_symbols (abfd
, info
);
8713 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8715 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8718 bfd_set_error (bfd_error_wrong_format
);
8724 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8726 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8727 unsigned char *content
;
8729 unsigned int sz
= 0;
8730 unsigned int lp_sz
= 0;
8731 unsigned int ca_sz
= 0;
8732 unsigned int qr_sz
= 0;
8733 unsigned int shrimg_cnt
= 0;
8734 unsigned int chgprt_num
= 0;
8735 unsigned int chgprt_sz
= 0;
8736 struct vms_eiaf
*eiaf
;
8740 /* Shared libraries. */
8741 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8743 struct alpha_vms_shlib_el
*shlib
;
8745 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8747 if (!shlib
->has_fixups
)
8752 if (VEC_COUNT (shlib
->ca
) > 0)
8754 /* Header + entries. */
8756 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8758 if (VEC_COUNT (shlib
->lp
) > 0)
8760 /* Header + entries. */
8762 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8764 if (VEC_COUNT (shlib
->qr
) > 0)
8766 /* Header + entries. */
8768 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8779 /* Finish now if there is no content. */
8780 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8783 /* Add an eicp entry for the fixup itself. */
8785 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8787 /* This isect could be made RO or EXE after relocations are applied. */
8788 if ((sec
->flags
& SEC_RELOC
) != 0
8789 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8792 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8794 /* Allocate section content (round-up size) */
8795 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8796 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8797 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8798 content
= bfd_zalloc (info
->output_bfd
, sz
);
8799 if (content
== NULL
)
8802 sec
= alpha_vms_link_hash (info
)->fixup
;
8803 sec
->contents
= content
;
8806 eiaf
= (struct vms_eiaf
*)content
;
8807 off
= sizeof (struct vms_eiaf
);
8808 bfd_putl32 (0, eiaf
->majorid
);
8809 bfd_putl32 (0, eiaf
->minorid
);
8810 bfd_putl32 (0, eiaf
->iaflink
);
8811 bfd_putl32 (0, eiaf
->fixuplnk
);
8812 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8813 bfd_putl32 (0, eiaf
->flags
);
8814 bfd_putl32 (0, eiaf
->qrelfixoff
);
8815 bfd_putl32 (0, eiaf
->lrelfixoff
);
8816 bfd_putl32 (0, eiaf
->qdotadroff
);
8817 bfd_putl32 (0, eiaf
->ldotadroff
);
8818 bfd_putl32 (0, eiaf
->codeadroff
);
8819 bfd_putl32 (0, eiaf
->lpfixoff
);
8820 bfd_putl32 (0, eiaf
->chgprtoff
);
8821 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8822 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8823 bfd_putl32 (0, eiaf
->shlextra
);
8824 bfd_putl32 (0, eiaf
->permctx
);
8825 bfd_putl32 (0, eiaf
->base_va
);
8826 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8833 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8835 struct alpha_vms_shlib_el
*shlib
;
8836 struct vms_shl
*shl
;
8838 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8840 if (!shlib
->has_fixups
)
8843 /* Renumber shared images. */
8844 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8846 shl
= (struct vms_shl
*)(content
+ off
);
8847 bfd_putl32 (0, shl
->baseva
);
8848 bfd_putl32 (0, shl
->shlptr
);
8849 bfd_putl32 (0, shl
->ident
);
8850 bfd_putl32 (0, shl
->permctx
);
8851 shl
->size
= sizeof (struct vms_shl
);
8852 bfd_putl16 (0, shl
->fill_1
);
8854 bfd_putl32 (0, shl
->icb
);
8855 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8856 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8859 off
+= sizeof (struct vms_shl
);
8865 bfd_putl32 (off
, eiaf
->codeadroff
);
8867 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8869 struct alpha_vms_shlib_el
*shlib
;
8872 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8874 if (VEC_COUNT (shlib
->ca
) == 0)
8877 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8878 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8881 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8883 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8889 bfd_putl32 (0, content
+ off
);
8890 bfd_putl32 (0, content
+ off
+ 4);
8897 bfd_putl32 (off
, eiaf
->lpfixoff
);
8899 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8901 struct alpha_vms_shlib_el
*shlib
;
8904 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8906 if (VEC_COUNT (shlib
->lp
) == 0)
8909 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8910 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8913 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8915 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8921 bfd_putl32 (0, content
+ off
);
8922 bfd_putl32 (0, content
+ off
+ 4);
8929 bfd_putl32 (off
, eiaf
->qdotadroff
);
8931 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8933 struct alpha_vms_shlib_el
*shlib
;
8936 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8938 if (VEC_COUNT (shlib
->qr
) == 0)
8941 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8942 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8945 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8947 struct alpha_vms_vma_ref
*r
;
8948 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8949 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8950 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8955 bfd_putl32 (0, content
+ off
);
8956 bfd_putl32 (0, content
+ off
+ 4);
8961 /* Write the change protection table. */
8962 bfd_putl32 (off
, eiaf
->chgprtoff
);
8963 bfd_putl32 (chgprt_num
, content
+ off
);
8966 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8968 struct vms_eicp
*eicp
;
8971 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8972 strcmp (sec
->name
, "$FIXUP$") == 0)
8974 else if ((sec
->flags
& SEC_RELOC
) != 0
8975 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8980 eicp
= (struct vms_eicp
*)(content
+ off
);
8981 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8982 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8984 bfd_putl32 (prot
, eicp
->newprt
);
8985 off
+= sizeof (struct vms_eicp
);
8991 /* Called by bfd_hash_traverse to fill the symbol table.
8992 Return FALSE in case of failure. */
8995 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8997 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8998 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8999 struct alpha_vms_link_hash_entry
*h
;
9000 struct vms_symbol_entry
*sym
;
9002 if (hc
->type
== bfd_link_hash_warning
)
9005 if (hc
->type
== bfd_link_hash_new
)
9008 h
= (struct alpha_vms_link_hash_entry
*) hc
;
9010 switch (h
->root
.type
)
9012 case bfd_link_hash_undefined
:
9014 case bfd_link_hash_new
:
9015 case bfd_link_hash_warning
:
9017 case bfd_link_hash_undefweak
:
9019 case bfd_link_hash_defined
:
9020 case bfd_link_hash_defweak
:
9022 asection
*sec
= h
->root
.u
.def
.section
;
9024 /* FIXME: this is certainly a symbol from a dynamic library. */
9025 if (bfd_is_abs_section (sec
))
9028 if (sec
->owner
->flags
& DYNAMIC
)
9032 case bfd_link_hash_common
:
9034 case bfd_link_hash_indirect
:
9038 /* Do not write not kept symbols. */
9039 if (info
->strip
== strip_some
9040 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
9041 FALSE
, FALSE
) != NULL
)
9046 /* This symbol doesn't come from a VMS object. So we suppose it is
9048 int len
= strlen (h
->root
.root
.string
);
9050 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
9051 sizeof (*sym
) + len
);
9055 memcpy (sym
->name
, h
->root
.root
.string
, len
);
9057 sym
->owner
= info
->output_bfd
;
9059 sym
->typ
= EGSD__C_SYMG
;
9061 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
9062 sym
->symbol_vector
= h
->root
.u
.def
.value
;
9063 sym
->section
= h
->root
.u
.def
.section
;
9064 sym
->value
= h
->root
.u
.def
.value
;
9069 if (!add_symbol_entry (info
->output_bfd
, sym
))
9076 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
9079 struct bfd_link_order
*p
;
9087 if (bfd_link_relocatable (info
))
9089 /* FIXME: we do not yet support relocatable link. It is not obvious
9090 how to do it for debug infos. */
9091 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
9095 abfd
->outsymbols
= NULL
;
9098 /* Mark all sections which will be included in the output file. */
9099 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9100 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9101 if (p
->type
== bfd_indirect_link_order
)
9102 p
->u
.indirect
.section
->linker_mark
= TRUE
;
9105 /* Handle all the link order information for the sections. */
9106 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9108 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
9109 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
9111 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9113 printf (" at 0x%08x - 0x%08x: ",
9114 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
9117 case bfd_section_reloc_link_order
:
9118 case bfd_symbol_reloc_link_order
:
9119 printf (" section/symbol reloc\n");
9121 case bfd_indirect_link_order
:
9122 printf (" section %s of %s\n",
9123 p
->u
.indirect
.section
->name
,
9124 p
->u
.indirect
.section
->owner
->filename
);
9126 case bfd_data_link_order
:
9127 printf (" explicit data\n");
9130 printf (" *unknown* type %u\n", p
->type
);
9137 /* Generate the symbol table. */
9138 BFD_ASSERT (PRIV (syms
) == NULL
);
9139 if (info
->strip
!= strip_all
)
9140 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
9142 /* Find the entry point. */
9143 if (bfd_get_start_address (abfd
) == 0)
9145 bfd
*startbfd
= NULL
;
9147 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9149 /* Consider only VMS object files. */
9150 if (sub
->xvec
!= abfd
->xvec
)
9153 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
9155 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
9157 if (startbfd
!= NULL
9158 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
9160 (*info
->callbacks
->einfo
)
9161 /* xgettext:c-format */
9162 (_("%P: multiple entry points: in modules %pB and %pB\n"),
9171 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
9172 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
9175 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
9177 bfd_set_start_address
9178 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
9182 /* Set transfer addresses. */
9185 struct bfd_link_hash_entry
*h
;
9188 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
9189 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
9190 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
9191 PRIV (transfer_address
[i
++]) =
9192 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
9193 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
9195 PRIV (transfer_address
[i
++]) = 0;
9198 /* Allocate contents.
9199 Also compute the virtual base address. */
9200 base_addr
= (bfd_vma
)-1;
9202 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9204 if (o
->flags
& SEC_HAS_CONTENTS
)
9206 o
->contents
= bfd_alloc (abfd
, o
->size
);
9207 if (o
->contents
== NULL
)
9210 if (o
->flags
& SEC_LOAD
)
9212 if (o
->vma
< base_addr
)
9214 if (o
->vma
+ o
->size
> last_addr
)
9215 last_addr
= o
->vma
+ o
->size
;
9217 /* Clear the RELOC flags. Currently we don't support incremental
9218 linking. We use the RELOC flag for computing the eicp entries. */
9219 o
->flags
&= ~SEC_RELOC
;
9222 /* Create the fixup section. */
9223 fixupsec
= bfd_make_section_anyway_with_flags
9224 (info
->output_bfd
, "$FIXUP$",
9225 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9226 if (fixupsec
== NULL
)
9228 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
9229 fixupsec
->vma
= last_addr
;
9231 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
9232 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
9234 /* Create the DMT section, if necessary. */
9235 BFD_ASSERT (PRIV (dst_section
) == NULL
);
9236 dst
= bfd_get_section_by_name (abfd
, "$DST$");
9237 if (dst
!= NULL
&& dst
->size
== 0)
9241 PRIV (dst_section
) = dst
;
9242 dmt
= bfd_make_section_anyway_with_flags
9243 (info
->output_bfd
, "$DMT$",
9244 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
9251 /* Read all sections from the inputs. */
9252 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9254 if (sub
->flags
& DYNAMIC
)
9256 alpha_vms_create_eisd_for_shared (abfd
, sub
);
9260 if (!alpha_vms_read_sections_content (sub
, info
))
9264 /* Handle all the link order information for the sections.
9265 Note: past this point, it is not possible to create new sections. */
9266 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
9268 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
9272 case bfd_section_reloc_link_order
:
9273 case bfd_symbol_reloc_link_order
:
9276 case bfd_indirect_link_order
:
9280 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
9287 /* Compute fixups. */
9288 if (!alpha_vms_build_fixups (info
))
9291 /* Compute the DMT. */
9295 unsigned char *contents
= NULL
;
9297 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
9298 for (pass
= 0; pass
< 2; pass
++)
9300 unsigned int off
= 0;
9302 /* For each object file (ie for each module). */
9303 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
9306 struct vms_dmt_header
*dmth
= NULL
;
9307 unsigned int psect_count
;
9309 /* Skip this module if it has no DST. */
9310 sub_dst
= PRIV2 (sub
, dst_section
);
9311 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
9316 /* Write the header. */
9317 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
9318 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
9319 bfd_putl32 (sub_dst
->size
, dmth
->size
);
9322 off
+= sizeof (struct vms_dmt_header
);
9325 /* For each section (ie for each psect). */
9326 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
9328 /* Only consider interesting sections. */
9329 if (!(o
->flags
& SEC_ALLOC
))
9331 if (o
->flags
& SEC_LINKER_CREATED
)
9336 /* Write an entry. */
9337 struct vms_dmt_psect
*dmtp
;
9339 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
9340 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
9342 bfd_putl32 (o
->size
, dmtp
->length
);
9345 off
+= sizeof (struct vms_dmt_psect
);
9348 bfd_putl32 (psect_count
, dmth
->psect_count
);
9353 contents
= bfd_zalloc (info
->output_bfd
, off
);
9354 if (contents
== NULL
)
9356 dmt
->contents
= contents
;
9361 BFD_ASSERT (off
== dmt
->size
);
9369 /* Read the contents of a section.
9370 buf points to a buffer of buf_size bytes to be filled with
9371 section data (starting at offset into section) */
9374 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
9375 void *buf
, file_ptr offset
,
9376 bfd_size_type count
)
9380 /* Image are easy. */
9381 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
9382 return _bfd_generic_get_section_contents (abfd
, section
,
9383 buf
, offset
, count
);
9386 if (offset
+ count
< count
9387 || offset
+ count
> section
->size
)
9389 bfd_set_error (bfd_error_invalid_operation
);
9393 /* If the section is already in memory, just copy it. */
9394 if (section
->flags
& SEC_IN_MEMORY
)
9396 BFD_ASSERT (section
->contents
!= NULL
);
9397 memcpy (buf
, section
->contents
+ offset
, count
);
9400 if (section
->size
== 0)
9403 /* Alloc in memory and read ETIRs. */
9404 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9406 BFD_ASSERT (sec
->contents
== NULL
);
9408 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9410 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9411 if (sec
->contents
== NULL
)
9415 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9417 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9419 sec
->flags
|= SEC_IN_MEMORY
;
9420 memcpy (buf
, section
->contents
+ offset
, count
);
9425 /* Set the format of a file being written. */
9428 alpha_vms_mkobject (bfd
* abfd
)
9430 const bfd_arch_info_type
*arch
;
9432 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9434 if (!vms_initialize (abfd
))
9437 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9438 if (PRIV (recwr
.buf
) == NULL
)
9441 arch
= bfd_scan_arch ("alpha");
9445 bfd_set_error (bfd_error_wrong_format
);
9449 abfd
->arch_info
= arch
;
9456 /* Called when the BFD is being closed to do any necessary cleanup. */
9459 vms_close_and_cleanup (bfd
* abfd
)
9461 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9463 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9466 if (abfd
->format
== bfd_object
)
9468 alpha_vms_free_private (abfd
);
9471 if (abfd
->direction
== write_direction
)
9473 /* Last step on VMS is to convert the file to variable record length
9475 if (!bfd_cache_close (abfd
))
9477 if (!_bfd_vms_convert_to_var_unix_filename (abfd
->filename
))
9483 return _bfd_generic_close_and_cleanup (abfd
);
9486 /* Called when a new section is created. */
9489 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9493 vms_debug2 ((1, "vms_new_section_hook (%p, [%u]%s)\n",
9494 abfd
, section
->index
, section
->name
));
9496 if (!bfd_set_section_alignment (section
, 0))
9499 vms_debug2 ((7, "%u: %s\n", section
->index
, section
->name
));
9501 amt
= sizeof (struct vms_section_data_struct
);
9502 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9503 if (section
->used_by_bfd
== NULL
)
9506 /* Create the section symbol. */
9507 return _bfd_generic_new_section_hook (abfd
, section
);
9510 /* Part 4.5, symbols. */
9512 /* Print symbol to file according to how. how is one of
9513 bfd_print_symbol_name just print the name
9514 bfd_print_symbol_more print more (???)
9515 bfd_print_symbol_all print all we know, which is not much right now :-). */
9518 vms_print_symbol (bfd
* abfd
,
9521 bfd_print_symbol_type how
)
9523 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9524 abfd
, file
, symbol
, how
));
9528 case bfd_print_symbol_name
:
9529 case bfd_print_symbol_more
:
9530 fprintf ((FILE *)file
," %s", symbol
->name
);
9533 case bfd_print_symbol_all
:
9535 const char *section_name
= symbol
->section
->name
;
9537 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9539 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9545 /* Return information about symbol in ret.
9547 fill type, value and name
9550 B bss segment symbol
9552 D data segment symbol
9554 t a static function symbol
9555 T text segment symbol
9560 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9566 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9568 sec
= symbol
->section
;
9575 else if (bfd_is_com_section (sec
))
9577 else if (bfd_is_abs_section (sec
))
9579 else if (bfd_is_und_section (sec
))
9581 else if (bfd_is_ind_section (sec
))
9583 else if ((symbol
->flags
& BSF_FUNCTION
)
9584 || (bfd_section_flags (sec
) & SEC_CODE
))
9586 else if (bfd_section_flags (sec
) & SEC_DATA
)
9588 else if (bfd_section_flags (sec
) & SEC_ALLOC
)
9593 if (ret
->type
!= 'U')
9594 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9597 ret
->name
= symbol
->name
;
9600 /* Return TRUE if the given symbol sym in the BFD abfd is
9601 a compiler generated local label, else return FALSE. */
9604 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9607 return name
[0] == '$';
9610 /* Part 4.7, writing an object file. */
9612 /* Sets the contents of the section section in BFD abfd to the data starting
9613 in memory at LOCATION. The data is written to the output section starting
9614 at offset offset for count bytes.
9616 Normally TRUE is returned, else FALSE. Possible error returns are:
9617 o bfd_error_no_contents - The output section does not have the
9618 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9619 o and some more too */
9622 _bfd_vms_set_section_contents (bfd
* abfd
,
9624 const void * location
,
9626 bfd_size_type count
)
9628 if (section
->contents
== NULL
)
9630 section
->contents
= bfd_alloc (abfd
, section
->size
);
9631 if (section
->contents
== NULL
)
9634 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9640 /* Set the architecture and machine type in BFD abfd to arch and mach.
9641 Find the correct pointer to a structure and insert it into the arch_info
9645 alpha_vms_set_arch_mach (bfd
*abfd
,
9646 enum bfd_architecture arch
, unsigned long mach
)
9648 if (arch
!= bfd_arch_alpha
9649 && arch
!= bfd_arch_unknown
)
9652 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9655 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9658 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9659 asection
*sec
, flagword no_flags
, flagword flags
)
9661 vms_section_data (sec
)->no_flags
= no_flags
;
9662 vms_section_data (sec
)->flags
= flags
;
9665 struct vms_private_data_struct
*
9666 bfd_vms_get_data (bfd
*abfd
)
9668 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9671 #define vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9672 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9673 #define vms_bfd_copy_link_hash_symbol_type \
9674 _bfd_generic_copy_link_hash_symbol_type
9675 #define vms_bfd_is_group_section bfd_generic_is_group_section
9676 #define vms_bfd_group_name bfd_generic_group_name
9677 #define vms_bfd_discard_group bfd_generic_discard_group
9678 #define vms_section_already_linked _bfd_generic_section_already_linked
9679 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9680 #define vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9681 #define vms_bfd_define_start_stop bfd_generic_define_start_stop
9682 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9684 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9685 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9686 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9687 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9688 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9689 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9691 /* Symbols table. */
9692 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9693 #define alpha_vms_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
9694 #define alpha_vms_print_symbol vms_print_symbol
9695 #define alpha_vms_get_symbol_info vms_get_symbol_info
9696 #define alpha_vms_get_symbol_version_string \
9697 _bfd_nosymbols_get_symbol_version_string
9699 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9700 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9701 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9702 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9703 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9704 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9705 #define alpha_vms_find_line _bfd_nosymbols_find_line
9706 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9708 /* Generic table. */
9709 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9710 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9711 #define alpha_vms_new_section_hook vms_new_section_hook
9712 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9713 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9715 #define alpha_vms_bfd_get_relocated_section_contents \
9716 bfd_generic_get_relocated_section_contents
9718 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9719 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9720 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9721 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9722 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9723 #define alpha_vms_bfd_group_name bfd_generic_group_name
9724 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9725 #define alpha_vms_section_already_linked \
9726 _bfd_generic_section_already_linked
9728 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9729 #define alpha_vms_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
9730 #define alpha_vms_bfd_define_start_stop bfd_generic_define_start_stop
9731 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9732 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9733 _bfd_generic_copy_link_hash_symbol_type
9735 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9737 #define alpha_vms_get_dynamic_symtab_upper_bound \
9738 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9739 #define alpha_vms_canonicalize_dynamic_symtab \
9740 _bfd_nodynamic_canonicalize_dynamic_symtab
9741 #define alpha_vms_get_dynamic_reloc_upper_bound \
9742 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9743 #define alpha_vms_canonicalize_dynamic_reloc \
9744 _bfd_nodynamic_canonicalize_dynamic_reloc
9745 #define alpha_vms_bfd_link_check_relocs _bfd_generic_link_check_relocs
9747 const bfd_target alpha_vms_vec
=
9749 "vms-alpha", /* Name. */
9750 bfd_target_evax_flavour
,
9751 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9752 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9754 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9755 | WP_TEXT
| D_PAGED
), /* Object flags. */
9756 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9757 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9758 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9759 0, /* symbol_leading_char. */
9760 ' ', /* ar_pad_char. */
9761 15, /* ar_max_namelen. */
9762 0, /* match priority. */
9763 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9764 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9765 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9766 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9767 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9768 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9770 { /* bfd_check_format. */
9773 _bfd_vms_lib_alpha_archive_p
,
9776 { /* bfd_set_format. */
9777 _bfd_bool_bfd_false_error
,
9779 _bfd_vms_lib_alpha_mkarchive
,
9780 _bfd_bool_bfd_false_error
9782 { /* bfd_write_contents. */
9783 _bfd_bool_bfd_false_error
,
9784 alpha_vms_write_object_contents
,
9785 _bfd_vms_lib_write_archive_contents
,
9786 _bfd_bool_bfd_false_error
9789 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9790 BFD_JUMP_TABLE_COPY (vms
),
9791 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9792 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9793 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9794 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9795 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9796 BFD_JUMP_TABLE_LINK (alpha_vms
),
9797 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),