1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2015 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
54 #include "vms/esgps.h"
63 #include "vms/esdfm.h"
64 #include "vms/esdfv.h"
70 #include "vms/internal.h"
73 #define MIN(a,b) ((a) < (b) ? (a) : (b))
75 /* The r_type field in a reloc is one of the following values. */
76 #define ALPHA_R_IGNORE 0
77 #define ALPHA_R_REFQUAD 1
78 #define ALPHA_R_BRADDR 2
79 #define ALPHA_R_HINT 3
80 #define ALPHA_R_SREL16 4
81 #define ALPHA_R_SREL32 5
82 #define ALPHA_R_SREL64 6
83 #define ALPHA_R_OP_PUSH 7
84 #define ALPHA_R_OP_STORE 8
85 #define ALPHA_R_OP_PSUB 9
86 #define ALPHA_R_OP_PRSHIFT 10
87 #define ALPHA_R_LINKAGE 11
88 #define ALPHA_R_REFLONG 12
89 #define ALPHA_R_CODEADDR 13
90 #define ALPHA_R_NOP 14
91 #define ALPHA_R_BSR 15
92 #define ALPHA_R_LDA 16
93 #define ALPHA_R_BOH 17
95 /* These are used with DST_S_C_LINE_NUM. */
96 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
98 /* These are used with DST_S_C_SOURCE */
100 #define DST_S_B_PCLINE_UNSBYTE 1
101 #define DST_S_W_PCLINE_UNSWORD 1
102 #define DST_S_L_PCLINE_UNSLONG 1
104 #define DST_S_B_MODBEG_NAME 14
105 #define DST_S_L_RTNBEG_ADDRESS 5
106 #define DST_S_B_RTNBEG_NAME 13
107 #define DST_S_L_RTNEND_SIZE 5
109 /* These are used with DST_S_C_SOURCE. */
110 #define DST_S_C_SOURCE_HEADER_SIZE 4
112 #define DST_S_B_SRC_DF_LENGTH 1
113 #define DST_S_W_SRC_DF_FILEID 3
114 #define DST_S_B_SRC_DF_FILENAME 20
115 #define DST_S_B_SRC_UNSBYTE 1
116 #define DST_S_W_SRC_UNSWORD 1
117 #define DST_S_L_SRC_UNSLONG 1
119 /* Debugger symbol definitions. */
121 #define DBG_S_L_DMT_MODBEG 0
122 #define DBG_S_L_DST_SIZE 4
123 #define DBG_S_W_DMT_PSECT_COUNT 8
124 #define DBG_S_C_DMT_HEADER_SIZE 12
126 #define DBG_S_L_DMT_PSECT_START 0
127 #define DBG_S_L_DMT_PSECT_LENGTH 4
128 #define DBG_S_C_DMT_PSECT_SIZE 8
130 /* VMS module header. */
146 #define EMH_DATE_LENGTH 17
148 /* VMS End-Of-Module records (EOM/EEOM). */
152 unsigned int eom_l_total_lps
;
153 unsigned short eom_w_comcod
;
154 bfd_boolean eom_has_transfer
;
155 unsigned char eom_b_tfrflg
;
156 unsigned int eom_l_psindx
;
157 unsigned int eom_l_tfradr
;
160 struct vms_symbol_entry
166 unsigned char data_type
;
167 unsigned short flags
;
169 /* Section and offset/value of the symbol. */
173 /* Section and offset/value for the entry point (only for subprg). */
174 asection
*code_section
;
175 unsigned int code_value
;
177 /* Symbol vector offset. */
178 unsigned int symbol_vector
;
180 /* Length of the name. */
181 unsigned char namelen
;
186 /* Stack value for push/pop commands. */
194 #define STACKSIZE 128
196 /* A minimal decoding of DST compilation units. We only decode
197 what's needed to get to the line number information. */
207 struct srecinfo
*next
;
215 struct lineinfo
*next
;
222 struct funcinfo
*next
;
230 /* Chain the previously read compilation unit. */
233 /* The module name. */
236 /* The start offset and size of debug info in the DST section. */
240 /* The lowest and highest addresses contained in this compilation
241 unit as specified in the compilation unit header. */
245 /* The listing line table. */
246 struct lineinfo
*line_table
;
248 /* The source record table. */
249 struct srecinfo
*srec_table
;
251 /* A list of the functions found in this module. */
252 struct funcinfo
*func_table
;
254 /* Current allocation of file_table. */
255 unsigned int file_table_count
;
257 /* An array of the files making up this module. */
258 struct fileinfo
*file_table
;
261 /* BFD private data for alpha-vms. */
263 struct vms_private_data_struct
265 /* If true, relocs have been read. */
266 bfd_boolean reloc_done
;
268 /* Record input buffer. */
269 struct vms_rec_rd recrd
;
270 struct vms_rec_wr recwr
;
272 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
273 struct eom_struct eom_data
; /* data from EOM/EEOM record */
275 /* Transfer addresses (entry points). */
276 bfd_vma transfer_address
[4];
278 /* Array of GSD sections to get the correspond BFD one. */
279 unsigned int section_max
; /* Size of the sections array. */
280 unsigned int section_count
; /* Number of GSD sections. */
283 /* Array of raw symbols. */
284 struct vms_symbol_entry
**syms
;
286 /* Canonicalized symbols. */
289 /* Number of symbols. */
290 unsigned int gsd_sym_count
;
291 /* Size of the syms array. */
292 unsigned int max_sym_count
;
293 /* Number of procedure symbols. */
294 unsigned int norm_sym_count
;
296 /* Stack used to evaluate TIR/ETIR commands. */
297 struct stack_struct
*stack
;
300 /* Content reading. */
301 asection
*image_section
; /* section for image_ptr */
302 file_ptr image_offset
; /* Offset for image_ptr. */
304 struct module
*modules
; /* list of all compilation units */
306 /* The DST section. */
307 asection
*dst_section
;
309 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva
; /* relative virtual address of symbol vector */
315 unsigned char matchctl
;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index
;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map
*eisd_head
;
325 struct vms_internal_eisd_map
*eisd_tail
;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map
*gbl_eisd_head
;
329 struct vms_internal_eisd_map
*gbl_eisd_tail
;
331 /* linkage index counter used by conditional store commands */
332 unsigned int vms_linkage_index
;
335 #define PRIV2(abfd, name) \
336 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
337 #define PRIV(name) PRIV2(abfd,name)
340 /* Used to keep extra VMS specific information for a given section.
342 reloc_size holds the size of the relocation stream, note this
343 is very different from the number of relocations as VMS relocations
346 reloc_stream is the actual stream of relocation entries. */
348 struct vms_section_data_struct
350 /* Maximnum number of entries in sec->relocation. */
353 /* Corresponding eisd. Used only while generating executables. */
354 struct vms_internal_eisd_map
*eisd
;
356 /* PSC flags to be clear. */
359 /* PSC flags to be set. */
363 #define vms_section_data(sec) \
364 ((struct vms_section_data_struct *)sec->used_by_bfd)
366 /* To be called from the debugger. */
367 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*);
369 static int vms_get_remaining_object_record (bfd
*, unsigned int);
370 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
371 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
372 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
373 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
375 static void alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
377 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*);
378 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*);
387 /* Number of elements in VEC. */
389 #define VEC_COUNT(VEC) ((VEC).nbr_el)
391 /* Get the address of the Nth element. */
393 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
395 #define VEC_INIT(VEC) \
402 /* Be sure there is room for a new element. */
404 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
406 /* Allocate room for a new element and return its address. */
408 #define VEC_APPEND(VEC, TYPE) \
409 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
411 /* Append an element. */
413 #define VEC_APPEND_EL(VEC, TYPE, EL) \
414 (*(VEC_APPEND (VEC, TYPE)) = EL)
416 struct alpha_vms_vma_ref
418 bfd_vma vma
; /* Vma in the output. */
419 bfd_vma ref
; /* Reference in the input. */
422 struct alpha_vms_shlib_el
425 bfd_boolean has_fixups
;
427 struct vector_type lp
; /* Vector of bfd_vma. */
428 struct vector_type ca
; /* Vector of bfd_vma. */
429 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
432 /* Alpha VMS linker hash table. */
434 struct alpha_vms_link_hash_table
436 struct bfd_link_hash_table root
;
438 /* Vector of shared libraries. */
439 struct vector_type shrlibs
;
444 /* Base address. Used by fixups. */
448 #define alpha_vms_link_hash(INFO) \
449 ((struct alpha_vms_link_hash_table *)(INFO->hash))
451 /* Alpha VMS linker hash table entry. */
453 struct alpha_vms_link_hash_entry
455 struct bfd_link_hash_entry root
;
457 /* Pointer to the original vms symbol. */
458 struct vms_symbol_entry
*sym
;
463 /* Read & process EIHD record.
464 Return TRUE on success, FALSE on error. */
467 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
468 unsigned int *eihs_offset
)
470 unsigned int imgtype
, size
;
472 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
474 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
476 size
= bfd_getl32 (eihd
->size
);
477 imgtype
= bfd_getl32 (eihd
->imgtype
);
479 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
480 abfd
->flags
|= EXEC_P
;
482 symvva
= bfd_getl64 (eihd
->symvva
);
485 PRIV (symvva
) = symvva
;
486 abfd
->flags
|= DYNAMIC
;
489 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
490 PRIV (matchctl
) = eihd
->matchctl
;
492 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
493 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
495 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
496 size
, imgtype
, (unsigned long)symvva
,
497 *eisd_offset
, *eihs_offset
));
502 /* Read & process EISD record.
503 Return TRUE on success, FALSE on error. */
506 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
508 int section_count
= 0;
510 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
514 struct vms_eisd
*eisd
;
515 unsigned int rec_size
;
517 unsigned long long vaddr
;
524 /* PR 17512: file: 3d9e9fe9. */
525 if (offset
>= PRIV (recrd
.rec_size
))
527 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
528 rec_size
= bfd_getl32 (eisd
->eisdsize
);
532 /* Skip to next block if pad. */
533 if (rec_size
== 0xffffffff)
535 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
541 size
= bfd_getl32 (eisd
->secsize
);
542 vaddr
= bfd_getl64 (eisd
->virt_addr
);
543 flags
= bfd_getl32 (eisd
->flags
);
544 vbn
= bfd_getl32 (eisd
->vbn
);
546 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
547 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
549 /* VMS combines psects from .obj files into isects in the .exe. This
550 process doesn't preserve enough information to reliably determine
551 what's in each section without examining the data. This is
552 especially true of DWARF debug sections. */
553 bfd_flags
= SEC_ALLOC
;
555 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
557 if (flags
& EISD__M_EXE
)
558 bfd_flags
|= SEC_CODE
;
560 if (flags
& EISD__M_NONSHRADR
)
561 bfd_flags
|= SEC_DATA
;
563 if (!(flags
& EISD__M_WRT
))
564 bfd_flags
|= SEC_READONLY
;
566 if (flags
& EISD__M_DZRO
)
567 bfd_flags
|= SEC_DATA
;
569 if (flags
& EISD__M_FIXUPVEC
)
570 bfd_flags
|= SEC_DATA
;
572 if (flags
& EISD__M_CRF
)
573 bfd_flags
|= SEC_DATA
;
575 if (flags
& EISD__M_GBL
)
577 name
= _bfd_vms_save_counted_string (eisd
->gblnam
);
578 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
579 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
581 else if (flags
& EISD__M_FIXUPVEC
)
583 else if (eisd
->type
== EISD__K_USRSTACK
)
589 name
= (char*) bfd_alloc (abfd
, 32);
590 if (flags
& EISD__M_DZRO
)
592 else if (flags
& EISD__M_EXE
)
594 else if (!(flags
& EISD__M_WRT
))
598 BFD_ASSERT (section_count
< 999);
599 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
602 section
= bfd_make_section (abfd
, name
);
607 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
608 section
->size
= size
;
609 section
->vma
= vaddr
;
611 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
618 /* Read & process EIHS record.
619 Return TRUE on success, FALSE on error. */
622 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
624 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
625 unsigned int gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
626 unsigned int gstsize ATTRIBUTE_UNUSED
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
627 unsigned int dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
628 unsigned int dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
629 unsigned int dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
630 unsigned int dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
634 vms_debug (8, "_bfd_vms_slurp_ihs\n");
635 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
636 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
641 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
643 section
= bfd_make_section (abfd
, "$DST$");
647 section
->size
= dstsize
;
648 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
650 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
653 PRIV (dst_section
) = section
;
654 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
659 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
661 section
= bfd_make_section (abfd
, "$DMT$");
665 section
->size
= dmtbytes
;
666 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
668 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
674 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
676 bfd_set_error (bfd_error_file_truncated
);
680 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
683 abfd
->flags
|= HAS_SYMS
;
689 /* Object file reading. */
691 /* Object file input functions. */
693 /* Get next record from object file to vms_buf.
694 Set PRIV(buf_size) and return it
696 This is a little tricky since it should be portable.
698 The openVMS object file has 'variable length' which means that
699 read() returns data in chunks of (hopefully) correct and expected
700 size. The linker (and other tools on VMS) depend on that. Unix
701 doesn't know about 'formatted' files, so reading and writing such
702 an object file in a Unix environment is not trivial.
704 With the tool 'file' (available on all VMS FTP sites), one
705 can view and change the attributes of a file. Changing from
706 'variable length' to 'fixed length, 512 bytes' reveals the
707 record size at the first 2 bytes of every record. The same
708 may happen during the transfer of object files from VMS to Unix,
709 at least with UCX, the DEC implementation of TCP/IP.
711 The VMS format repeats the size at bytes 2 & 3 of every record.
713 On the first call (file_format == FF_UNKNOWN) we check if
714 the first and the third byte pair (!) of the record match.
715 If they do it's an object file in an Unix environment or with
716 wrong attributes (FF_FOREIGN), else we should be in a VMS
717 environment where read() returns the record size (FF_NATIVE).
719 Reading is always done in 2 steps:
720 1. first just the record header is read and the size extracted,
721 2. then the read buffer is adjusted and the remaining bytes are
724 All file I/O is done on even file positions. */
726 #define VMS_OBJECT_ADJUSTMENT 2
729 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
731 /* Set the file format once for all on the first invocation. */
732 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
734 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
735 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
736 PRIV (recrd
.file_format
) = FF_FOREIGN
;
738 PRIV (recrd
.file_format
) = FF_NATIVE
;
741 /* The adjustment is needed only in an Unix environment. */
742 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
743 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
746 /* Implement step #1 of the object record reading procedure.
747 Return the record type or -1 on failure. */
750 _bfd_vms_get_object_record (bfd
*abfd
)
752 unsigned int test_len
= 6;
755 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
757 /* Skip alignment byte if the current position is odd. */
758 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
760 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
762 bfd_set_error (bfd_error_file_truncated
);
767 /* Read the record header */
768 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
770 bfd_set_error (bfd_error_file_truncated
);
774 /* Reset the record pointer. */
775 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
776 maybe_adjust_record_pointer_for_object (abfd
);
778 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
781 type
= bfd_getl16 (PRIV (recrd
.rec
));
783 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
784 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
789 /* Implement step #2 of the object record reading procedure.
790 Return the size of the record or 0 on failure. */
793 vms_get_remaining_object_record (bfd
*abfd
, unsigned int read_so_far
)
795 unsigned int to_read
;
797 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
799 /* Extract record size. */
800 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
802 if (PRIV (recrd
.rec_size
) == 0)
804 bfd_set_error (bfd_error_file_truncated
);
808 /* That's what the linker manual says. */
809 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
811 bfd_set_error (bfd_error_file_truncated
);
815 /* Take into account object adjustment. */
816 to_read
= PRIV (recrd
.rec_size
);
817 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
818 to_read
+= VMS_OBJECT_ADJUSTMENT
;
820 /* Adjust the buffer. */
821 if (to_read
> PRIV (recrd
.buf_size
))
824 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
825 if (PRIV (recrd
.buf
) == NULL
)
827 PRIV (recrd
.buf_size
) = to_read
;
829 /* PR 17512: file: 025-1974-0.004. */
830 else if (to_read
<= read_so_far
)
833 /* Read the remaining record. */
834 to_read
-= read_so_far
;
836 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
838 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
840 bfd_set_error (bfd_error_file_truncated
);
844 /* Reset the record pointer. */
845 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
846 maybe_adjust_record_pointer_for_object (abfd
);
848 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
849 PRIV (recrd
.rec_size
)));
851 return PRIV (recrd
.rec_size
);
854 /* Read and process emh record.
855 Return TRUE on success, FALSE on error. */
858 _bfd_vms_slurp_ehdr (bfd
*abfd
)
861 unsigned char *vms_rec
;
865 vms_rec
= PRIV (recrd
.rec
);
866 /* PR 17512: file: 62736583. */
867 end
= PRIV (recrd
.buf
) + PRIV (recrd
.buf_size
);
869 vms_debug2 ((2, "HDR/EMH\n"));
871 subtype
= bfd_getl16 (vms_rec
+ 4);
873 vms_debug2 ((3, "subtype %d\n", subtype
));
879 if (vms_rec
+ 21 >= end
)
881 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
882 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
883 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
884 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
885 if ((vms_rec
+ 20 + vms_rec
[20] + 1) >= end
)
887 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20);
888 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
889 if ((ptr
+ *ptr
+ 1) >= end
)
891 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
);
895 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
899 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
901 PRIV (hdr_data
).hdr_c_lnm
=
902 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
906 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
908 PRIV (hdr_data
).hdr_c_src
=
909 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
913 if (vms_rec
+ PRIV (recrd
.rec_size
- 6) > end
)
915 PRIV (hdr_data
).hdr_c_ttl
=
916 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
926 bfd_set_error (bfd_error_wrong_format
);
933 /* Typical sections for evax object files. */
935 #define EVAX_ABS_NAME "$ABS$"
936 #define EVAX_CODE_NAME "$CODE$"
937 #define EVAX_LINK_NAME "$LINK$"
938 #define EVAX_DATA_NAME "$DATA$"
939 #define EVAX_BSS_NAME "$BSS$"
940 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
941 #define EVAX_READONLY_NAME "$READONLY$"
942 #define EVAX_LITERAL_NAME "$LITERAL$"
943 #define EVAX_LITERALS_NAME "$LITERALS"
944 #define EVAX_COMMON_NAME "$COMMON$"
945 #define EVAX_LOCAL_NAME "$LOCAL$"
947 struct sec_flags_struct
949 const char *name
; /* Name of section. */
951 flagword flags_always
; /* Flags we set always. */
953 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
956 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
958 static const struct sec_flags_struct evax_section_flags
[] =
966 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
967 SEC_CODE
| SEC_READONLY
,
968 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
969 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
971 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
972 SEC_DATA
| SEC_READONLY
,
973 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
974 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
976 EGPS__V_REL
| EGPS__V_RD
,
977 SEC_DATA
| SEC_READONLY
,
978 EGPS__V_REL
| EGPS__V_RD
,
979 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
981 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
983 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
984 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
986 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
988 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
990 { EVAX_READONLYADDR_NAME
,
991 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
992 SEC_DATA
| SEC_READONLY
,
993 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
994 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
995 { EVAX_READONLY_NAME
,
996 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
997 SEC_DATA
| SEC_READONLY
,
998 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
999 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1001 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1003 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1004 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1005 { EVAX_LITERALS_NAME
,
1006 EGPS__V_PIC
| EGPS__V_OVR
,
1007 SEC_DATA
| SEC_READONLY
,
1008 EGPS__V_PIC
| EGPS__V_OVR
,
1009 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
1011 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1013 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
1014 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
1017 /* Retrieve BFD section flags by name and size. */
1020 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1026 while (section_flags
[i
].name
!= NULL
)
1028 if (strcmp (name
, section_flags
[i
].name
) == 0)
1031 return section_flags
[i
].flags_hassize
;
1033 return section_flags
[i
].flags_always
;
1038 return section_flags
[i
].flags_hassize
;
1039 return section_flags
[i
].flags_always
;
1042 /* Retrieve VMS section flags by name and size. */
1045 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1051 while (section_flags
[i
].name
!= NULL
)
1053 if (strcmp (name
, section_flags
[i
].name
) == 0)
1056 return section_flags
[i
].vflags_hassize
;
1058 return section_flags
[i
].vflags_always
;
1063 return section_flags
[i
].vflags_hassize
;
1064 return section_flags
[i
].vflags_always
;
1067 /* Add SYM to the symbol table of ABFD.
1068 Return FALSE in case of error. */
1071 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1073 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1075 if (PRIV (max_sym_count
) == 0)
1077 PRIV (max_sym_count
) = 128;
1078 PRIV (syms
) = bfd_malloc
1079 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1083 PRIV (max_sym_count
) *= 2;
1084 PRIV (syms
) = bfd_realloc
1086 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1088 if (PRIV (syms
) == NULL
)
1092 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1096 /* Create a symbol whose name is ASCIC and add it to ABFD.
1097 Return NULL in case of error. */
1099 static struct vms_symbol_entry
*
1100 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1102 struct vms_symbol_entry
*entry
;
1106 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1109 entry
->namelen
= len
;
1110 memcpy (entry
->name
, ascic
, len
);
1111 entry
->name
[len
] = 0;
1112 entry
->owner
= abfd
;
1114 if (!add_symbol_entry (abfd
, entry
))
1119 /* Read and process EGSD. Return FALSE on failure. */
1122 _bfd_vms_slurp_egsd (bfd
*abfd
)
1124 int gsd_type
, gsd_size
;
1125 unsigned char *vms_rec
;
1126 unsigned long base_addr
;
1128 vms_debug2 ((2, "EGSD\n"));
1130 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1131 PRIV (recrd
.rec_size
) -= 8;
1133 /* Calculate base address for each section. */
1136 while (PRIV (recrd
.rec_size
) > 0)
1138 vms_rec
= PRIV (recrd
.rec
);
1140 gsd_type
= bfd_getl16 (vms_rec
);
1141 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1143 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1148 /* Program section definition. */
1150 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1151 flagword new_flags
, vms_flags
;
1154 vms_flags
= bfd_getl16 (egps
->flags
);
1156 if ((vms_flags
& EGPS__V_REL
) == 0)
1158 /* Use the global absolute section for all
1159 absolute sections. */
1160 section
= bfd_abs_section_ptr
;
1165 unsigned long align_addr
;
1167 name
= _bfd_vms_save_counted_string (&egps
->namlng
);
1169 section
= bfd_make_section (abfd
, name
);
1173 section
->filepos
= 0;
1174 section
->size
= bfd_getl32 (egps
->alloc
);
1175 section
->alignment_power
= egps
->align
;
1177 vms_section_data (section
)->flags
= vms_flags
;
1178 vms_section_data (section
)->no_flags
= 0;
1180 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1182 if (section
->size
> 0)
1183 new_flags
|= SEC_LOAD
;
1184 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1186 /* Set RELOC and HAS_CONTENTS if the section is not
1187 demand-zero and not empty. */
1188 new_flags
|= SEC_HAS_CONTENTS
;
1189 if (vms_flags
& EGPS__V_REL
)
1190 new_flags
|= SEC_RELOC
;
1192 if (vms_flags
& EGPS__V_EXE
)
1194 /* Set CODE if section is executable. */
1195 new_flags
|= SEC_CODE
;
1196 new_flags
&= ~SEC_DATA
;
1198 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1201 /* Give a non-overlapping vma to non absolute sections. */
1202 align_addr
= (1 << section
->alignment_power
);
1203 if ((base_addr
% align_addr
) != 0)
1204 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1205 section
->vma
= (bfd_vma
)base_addr
;
1206 base_addr
+= section
->size
;
1209 /* Append it to the section array. */
1210 if (PRIV (section_count
) >= PRIV (section_max
))
1212 if (PRIV (section_max
) == 0)
1213 PRIV (section_max
) = 16;
1215 PRIV (section_max
) *= 2;
1216 PRIV (sections
) = bfd_realloc_or_free
1217 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1218 if (PRIV (sections
) == NULL
)
1222 PRIV (sections
)[PRIV (section_count
)] = section
;
1223 PRIV (section_count
)++;
1230 struct vms_symbol_entry
*entry
;
1231 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1234 old_flags
= bfd_getl16 (egsy
->flags
);
1235 if (old_flags
& EGSY__V_DEF
)
1236 nameoff
= ESDF__B_NAMLNG
;
1238 nameoff
= ESRF__B_NAMLNG
;
1240 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1244 /* Allow only duplicate reference. */
1245 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1248 if (entry
->typ
== 0)
1250 entry
->typ
= gsd_type
;
1251 entry
->data_type
= egsy
->datyp
;
1252 entry
->flags
= old_flags
;
1255 if (old_flags
& EGSY__V_DEF
)
1257 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1259 entry
->value
= bfd_getl64 (esdf
->value
);
1260 entry
->section
= PRIV (sections
)[bfd_getl32 (esdf
->psindx
)];
1262 if (old_flags
& EGSY__V_NORM
)
1264 PRIV (norm_sym_count
)++;
1266 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1267 entry
->code_section
=
1268 PRIV (sections
)[bfd_getl32 (esdf
->ca_psindx
)];
1276 struct vms_symbol_entry
*entry
;
1277 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1280 old_flags
= bfd_getl16 (egst
->header
.flags
);
1282 entry
= add_symbol (abfd
, &egst
->namlng
);
1287 entry
->typ
= gsd_type
;
1288 entry
->data_type
= egst
->header
.datyp
;
1289 entry
->flags
= old_flags
;
1291 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1293 if (old_flags
& EGSY__V_REL
)
1294 entry
->section
= PRIV (sections
)[bfd_getl32 (egst
->psindx
)];
1296 entry
->section
= bfd_abs_section_ptr
;
1298 entry
->value
= bfd_getl64 (egst
->lp_2
);
1300 if (old_flags
& EGSY__V_NORM
)
1302 PRIV (norm_sym_count
)++;
1304 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1305 entry
->code_section
= bfd_abs_section_ptr
;
1312 /* Currently ignored. */
1317 (*_bfd_error_handler
) (_("Unknown EGSD subtype %d"), gsd_type
);
1318 bfd_set_error (bfd_error_bad_value
);
1322 PRIV (recrd
.rec_size
) -= gsd_size
;
1323 PRIV (recrd
.rec
) += gsd_size
;
1326 if (PRIV (gsd_sym_count
) > 0)
1327 abfd
->flags
|= HAS_SYMS
;
1332 /* Stack routines for vms ETIR commands. */
1334 /* Push value and section index. */
1337 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1339 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1340 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1342 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1343 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1345 if (PRIV (stackptr
) >= STACKSIZE
)
1347 bfd_set_error (bfd_error_bad_value
);
1348 (*_bfd_error_handler
) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1353 /* Pop value and section index. */
1356 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1358 if (PRIV (stackptr
) == 0)
1360 bfd_set_error (bfd_error_bad_value
);
1361 (*_bfd_error_handler
) (_("Stack underflow in _bfd_vms_pop"));
1365 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1366 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1368 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1371 /* Routines to fill sections contents during tir/etir read. */
1373 /* Initialize image buffer pointer to be filled. */
1376 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1380 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1382 sec
= PRIV (sections
)[sect
];
1386 /* Reading contents to an output bfd. */
1388 if (sec
->output_section
== NULL
)
1390 /* Section discarded. */
1391 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1393 /* This is not used. */
1394 PRIV (image_section
) = NULL
;
1395 PRIV (image_offset
) = 0;
1398 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1399 PRIV (image_section
) = sec
->output_section
;
1403 PRIV (image_offset
) = vma
;
1404 PRIV (image_section
) = sec
;
1408 /* Increment image buffer pointer by offset. */
1411 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1413 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1415 PRIV (image_offset
) += offset
;
1418 /* Save current DST location counter under specified index. */
1421 dst_define_location (bfd
*abfd
, unsigned int loc
)
1423 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1425 /* Grow the ptr offset table if necessary. */
1426 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1428 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1429 (loc
+ 1) * sizeof (unsigned int));
1430 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1433 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1436 /* Restore saved DST location counter from specified index. */
1439 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1441 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1443 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1446 /* Retrieve saved DST location counter from specified index. */
1449 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1451 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1453 return PRIV (dst_ptr_offsets
)[loc
];
1456 /* Write multiple bytes to section image. */
1459 image_write (bfd
*abfd
, unsigned char *ptr
, int size
)
1462 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1463 (long)PRIV (image_offset
));
1464 _bfd_hexdump (9, ptr
, size
, 0);
1467 if (PRIV (image_section
)->contents
!= NULL
)
1469 asection
*sec
= PRIV (image_section
);
1470 file_ptr off
= PRIV (image_offset
);
1473 if (off
> (file_ptr
)sec
->size
1474 || size
> (file_ptr
)sec
->size
1475 || off
+ size
> (file_ptr
)sec
->size
)
1477 bfd_set_error (bfd_error_bad_value
);
1481 memcpy (sec
->contents
+ off
, ptr
, size
);
1484 PRIV (image_offset
) += size
;
1488 /* Write byte to section image. */
1491 image_write_b (bfd
* abfd
, unsigned int value
)
1493 unsigned char data
[1];
1495 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1499 return image_write (abfd
, data
, sizeof (data
));
1502 /* Write 2-byte word to image. */
1505 image_write_w (bfd
* abfd
, unsigned int value
)
1507 unsigned char data
[2];
1509 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1511 bfd_putl16 (value
, data
);
1512 return image_write (abfd
, data
, sizeof (data
));
1515 /* Write 4-byte long to image. */
1518 image_write_l (bfd
* abfd
, unsigned long value
)
1520 unsigned char data
[4];
1522 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1524 bfd_putl32 (value
, data
);
1525 return image_write (abfd
, data
, sizeof (data
));
1528 /* Write 8-byte quad to image. */
1531 image_write_q (bfd
* abfd
, bfd_vma value
)
1533 unsigned char data
[8];
1535 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1537 bfd_putl64 (value
, data
);
1538 return image_write (abfd
, data
, sizeof (data
));
1542 _bfd_vms_etir_name (int cmd
)
1546 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1547 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1548 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1549 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1550 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1551 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1552 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1553 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1554 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1555 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1556 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1557 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1558 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1559 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1560 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1561 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1562 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1563 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1564 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1565 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1566 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1567 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1568 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1569 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1570 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1571 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1572 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1573 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1574 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1575 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1576 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1577 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1578 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1579 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1580 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1581 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1582 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1583 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1584 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1585 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1586 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1587 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1588 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1589 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1590 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1591 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1592 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1593 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1594 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1597 /* These names have not yet been added to this switch statement. */
1598 (*_bfd_error_handler
) (_("unknown ETIR command %d"), cmd
);
1603 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1606 _bfd_vms_get_value (bfd
*abfd
, const unsigned char *ascic
,
1607 struct bfd_link_info
*info
,
1609 struct alpha_vms_link_hash_entry
**hp
)
1614 struct alpha_vms_link_hash_entry
*h
;
1616 /* Not linking. Do not try to resolve the symbol. */
1625 for (i
= 0; i
< len
; i
++)
1626 name
[i
] = ascic
[i
+ 1];
1629 h
= (struct alpha_vms_link_hash_entry
*)
1630 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1635 && (h
->root
.type
== bfd_link_hash_defined
1636 || h
->root
.type
== bfd_link_hash_defweak
))
1637 *vma
= h
->root
.u
.def
.value
1638 + h
->root
.u
.def
.section
->output_offset
1639 + h
->root
.u
.def
.section
->output_section
->vma
;
1640 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1644 if (!(*info
->callbacks
->undefined_symbol
)
1645 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
))
1653 #define RELC_SHR_BASE 0x10000
1654 #define RELC_SEC_BASE 0x20000
1655 #define RELC_MASK 0x0ffff
1658 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1660 /* Handle undefined symbols. */
1661 if (h
== NULL
|| h
->sym
== NULL
)
1664 if (h
->sym
->typ
== EGSD__C_SYMG
)
1666 if (h
->sym
->flags
& EGSY__V_REL
)
1667 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1670 /* Can this happen (non-relocatable symg) ? I'd like to see
1675 if (h
->sym
->typ
== EGSD__C_SYM
)
1677 if (h
->sym
->flags
& EGSY__V_REL
)
1686 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1688 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1692 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1693 unsigned int rel
, bfd_vma vma
)
1695 asection
*sec
= PRIV (sections
)[rel
& RELC_MASK
];
1699 if (sec
->output_section
== NULL
)
1701 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1704 return vma
+ sec
->vma
;
1707 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1708 the output section (used during linking).
1709 Return FALSE in case of error. */
1712 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1715 unsigned int length
;
1716 unsigned char *maxptr
;
1721 struct alpha_vms_link_hash_entry
*h
;
1723 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1724 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1726 ptr
= PRIV (recrd
.rec
);
1727 length
= PRIV (recrd
.rec_size
);
1728 maxptr
= ptr
+ length
;
1730 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1732 while (ptr
< maxptr
)
1734 int cmd
= bfd_getl16 (ptr
);
1735 int cmd_length
= bfd_getl16 (ptr
+ 2);
1740 _bfd_vms_debug (4, "etir: %s(%d)\n",
1741 _bfd_vms_etir_name (cmd
), cmd
);
1742 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1750 stack 32 bit value of symbol (high bits set to 0). */
1751 case ETIR__C_STA_GBL
:
1752 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1753 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1759 stack 32 bit value, sign extend to 64 bit. */
1760 case ETIR__C_STA_LW
:
1761 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1767 stack 64 bit value of symbol. */
1768 case ETIR__C_STA_QW
:
1769 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1772 /* Stack psect base plus quadword offset
1773 arg: lw section index
1774 qw signed quadword offset (low 32 bits)
1776 Stack qw argument and section index
1777 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1778 case ETIR__C_STA_PQ
:
1782 psect
= bfd_getl32 (ptr
);
1783 if ((unsigned int) psect
>= PRIV (section_count
))
1785 (*_bfd_error_handler
) (_("bad section index in %s"),
1786 _bfd_vms_etir_name (cmd
));
1787 bfd_set_error (bfd_error_bad_value
);
1790 op1
= bfd_getl64 (ptr
+ 4);
1791 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1795 case ETIR__C_STA_LI
:
1796 case ETIR__C_STA_MOD
:
1797 case ETIR__C_STA_CKARG
:
1798 (*_bfd_error_handler
) (_("unsupported STA cmd %s"),
1799 _bfd_vms_etir_name (cmd
));
1803 /* Store byte: pop stack, write byte
1806 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1807 if (rel1
!= RELC_NONE
)
1809 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1812 /* Store word: pop stack, write word
1815 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1816 if (rel1
!= RELC_NONE
)
1818 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1821 /* Store longword: pop stack, write longword
1823 case ETIR__C_STO_LW
:
1824 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1825 if (rel1
& RELC_SEC_BASE
)
1827 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1830 else if (rel1
& RELC_SHR_BASE
)
1832 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1835 if (rel1
!= RELC_NONE
)
1837 if (rel1
!= RELC_REL
)
1839 alpha_vms_add_lw_reloc (info
);
1841 image_write_l (abfd
, op1
);
1844 /* Store quadword: pop stack, write quadword
1846 case ETIR__C_STO_QW
:
1847 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1848 if (rel1
& RELC_SEC_BASE
)
1850 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1853 else if (rel1
& RELC_SHR_BASE
)
1855 if (rel1
!= RELC_NONE
)
1857 if (rel1
!= RELC_REL
)
1859 alpha_vms_add_qw_reloc (info
);
1861 image_write_q (abfd
, op1
);
1864 /* Store immediate repeated: pop stack for repeat count
1867 case ETIR__C_STO_IMMR
:
1871 size
= bfd_getl32 (ptr
);
1872 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1873 if (rel1
!= RELC_NONE
)
1876 image_write (abfd
, ptr
+ 4, size
);
1880 /* Store global: write symbol value
1881 arg: cs global symbol name. */
1882 case ETIR__C_STO_GBL
:
1883 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1886 if (h
->sym
->typ
== EGSD__C_SYMG
)
1888 alpha_vms_add_fixup_qr
1889 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
1894 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
1896 alpha_vms_add_qw_reloc (info
);
1899 image_write_q (abfd
, op1
);
1902 /* Store code address: write address of entry point
1903 arg: cs global symbol name (procedure). */
1904 case ETIR__C_STO_CA
:
1905 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1908 if (h
->sym
->flags
& EGSY__V_NORM
)
1910 /* That's really a procedure. */
1911 if (h
->sym
->typ
== EGSD__C_SYMG
)
1913 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
1914 op1
= h
->sym
->symbol_vector
;
1918 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1919 h
->sym
->code_value
);
1920 alpha_vms_add_qw_reloc (info
);
1925 /* Symbol is not a procedure. */
1929 image_write_q (abfd
, op1
);
1932 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1934 case ETIR__C_STO_OFF
:
1935 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1937 if (!(rel1
& RELC_SEC_BASE
))
1940 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1942 image_write_q (abfd
, op1
);
1946 arg: lw count of bytes
1948 case ETIR__C_STO_IMM
:
1952 size
= bfd_getl32 (ptr
);
1953 image_write (abfd
, ptr
+ 4, size
);
1957 /* This code is 'reserved to digital' according to the openVMS
1958 linker manual, however it is generated by the DEC C compiler
1959 and defined in the include file.
1960 FIXME, since the following is just a guess
1961 store global longword: store 32bit value of symbol
1962 arg: cs symbol name. */
1963 case ETIR__C_STO_GBL_LW
:
1964 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1968 image_write_l (abfd
, op1
);
1971 case ETIR__C_STO_RB
:
1972 case ETIR__C_STO_AB
:
1973 case ETIR__C_STO_LP_PSB
:
1974 (*_bfd_error_handler
) (_("%s: not supported"),
1975 _bfd_vms_etir_name (cmd
));
1978 case ETIR__C_STO_HINT_GBL
:
1979 case ETIR__C_STO_HINT_PS
:
1980 (*_bfd_error_handler
) (_("%s: not implemented"),
1981 _bfd_vms_etir_name (cmd
));
1985 /* 200 Store-conditional Linkage Pair
1987 case ETIR__C_STC_LP
:
1989 /* 202 Store-conditional Address at global address
1993 case ETIR__C_STC_GBL
:
1995 /* 203 Store-conditional Code Address at global address
1997 cs procedure name. */
1998 case ETIR__C_STC_GCA
:
2000 /* 204 Store-conditional Address at psect + offset
2004 case ETIR__C_STC_PS
:
2005 (*_bfd_error_handler
) (_("%s: not supported"),
2006 _bfd_vms_etir_name (cmd
));
2010 /* 201 Store-conditional Linkage Pair with Procedure Signature
2016 case ETIR__C_STC_LP_PSB
:
2017 _bfd_vms_get_value (abfd
, ptr
+ 4, info
, &op1
, &h
);
2020 if (h
->sym
->typ
== EGSD__C_SYMG
)
2022 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2023 op1
= h
->sym
->symbol_vector
;
2028 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2029 h
->sym
->code_value
);
2030 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2036 /* Undefined symbol. */
2040 image_write_q (abfd
, op1
);
2041 image_write_q (abfd
, op2
);
2044 /* 205 Store-conditional NOP at address of global
2046 case ETIR__C_STC_NOP_GBL
:
2049 /* 207 Store-conditional BSR at global address
2052 case ETIR__C_STC_BSR_GBL
:
2055 /* 209 Store-conditional LDA at global address
2058 case ETIR__C_STC_LDA_GBL
:
2061 /* 211 Store-conditional BSR or Hint at global address
2064 case ETIR__C_STC_BOH_GBL
:
2065 /* Currentl ignored. */
2068 /* 213 Store-conditional NOP,BSR or HINT at global address
2071 case ETIR__C_STC_NBH_GBL
:
2073 /* 206 Store-conditional NOP at pect + offset
2076 case ETIR__C_STC_NOP_PS
:
2078 /* 208 Store-conditional BSR at pect + offset
2081 case ETIR__C_STC_BSR_PS
:
2083 /* 210 Store-conditional LDA at psect + offset
2086 case ETIR__C_STC_LDA_PS
:
2088 /* 212 Store-conditional BSR or Hint at pect + offset
2091 case ETIR__C_STC_BOH_PS
:
2093 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2095 case ETIR__C_STC_NBH_PS
:
2096 (*_bfd_error_handler
) ("%s: not supported",
2097 _bfd_vms_etir_name (cmd
));
2101 /* Det relocation base: pop stack, set image location counter
2103 case ETIR__C_CTL_SETRB
:
2104 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2105 if (!(rel1
& RELC_SEC_BASE
))
2107 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2110 /* Augment relocation base: increment image location counter by offset
2111 arg: lw offset value. */
2112 case ETIR__C_CTL_AUGRB
:
2113 op1
= bfd_getl32 (ptr
);
2114 image_inc_ptr (abfd
, op1
);
2117 /* Define location: pop index, save location counter under index
2119 case ETIR__C_CTL_DFLOC
:
2120 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2121 if (rel1
!= RELC_NONE
)
2123 dst_define_location (abfd
, op1
);
2126 /* Set location: pop index, restore location counter from index
2128 case ETIR__C_CTL_STLOC
:
2129 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2130 if (rel1
!= RELC_NONE
)
2132 dst_restore_location (abfd
, op1
);
2135 /* Stack defined location: pop index, push location counter from index
2137 case ETIR__C_CTL_STKDL
:
2138 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2139 if (rel1
!= RELC_NONE
)
2141 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2144 case ETIR__C_OPR_NOP
: /* No-op. */
2147 case ETIR__C_OPR_ADD
: /* Add. */
2148 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2149 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2150 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2152 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2154 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2157 case ETIR__C_OPR_SUB
: /* Subtract. */
2158 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2159 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2160 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2162 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2164 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2165 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2168 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2170 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2173 case ETIR__C_OPR_MUL
: /* Multiply. */
2174 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2175 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2176 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2178 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2181 case ETIR__C_OPR_DIV
: /* Divide. */
2182 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2183 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2184 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2187 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2189 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2192 case ETIR__C_OPR_AND
: /* Logical AND. */
2193 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2194 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2195 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2197 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2200 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2201 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2202 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2203 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2205 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2208 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2209 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2210 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2211 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2213 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2216 case ETIR__C_OPR_NEG
: /* Negate. */
2217 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2218 if (rel1
!= RELC_NONE
)
2220 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2223 case ETIR__C_OPR_COM
: /* Complement. */
2224 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2225 if (rel1
!= RELC_NONE
)
2227 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2230 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2231 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2232 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2233 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2236 (*_bfd_error_handler
) (_("invalid use of %s with contexts"),
2237 _bfd_vms_etir_name (cmd
));
2240 if ((int)op2
< 0) /* Shift right. */
2242 else /* Shift left. */
2244 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2247 case ETIR__C_OPR_INSV
: /* Insert field. */
2248 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2249 case ETIR__C_OPR_ROT
: /* Rotate. */
2250 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2251 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2252 (*_bfd_error_handler
) (_("%s: not supported"),
2253 _bfd_vms_etir_name (cmd
));
2257 case ETIR__C_OPR_SEL
: /* Select. */
2258 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2260 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2263 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2264 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2265 _bfd_vms_push (abfd
, op1
, rel1
);
2270 (*_bfd_error_handler
) (_("reserved cmd %d"), cmd
);
2275 ptr
+= cmd_length
- 4;
2281 /* Process EDBG/ETBT record.
2282 Return TRUE on success, FALSE on error */
2285 vms_slurp_debug (bfd
*abfd
)
2287 asection
*section
= PRIV (dst_section
);
2289 if (section
== NULL
)
2291 /* We have no way to find out beforehand how much debug info there
2292 is in an object file, so pick an initial amount and grow it as
2294 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2297 section
= bfd_make_section (abfd
, "$DST$");
2300 if (!bfd_set_section_flags (abfd
, section
, flags
))
2302 PRIV (dst_section
) = section
;
2305 PRIV (image_section
) = section
;
2306 PRIV (image_offset
) = section
->size
;
2308 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2311 section
->size
= PRIV (image_offset
);
2315 /* Process EDBG record.
2316 Return TRUE on success, FALSE on error. */
2319 _bfd_vms_slurp_edbg (bfd
*abfd
)
2321 vms_debug2 ((2, "EDBG\n"));
2323 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2325 return vms_slurp_debug (abfd
);
2328 /* Process ETBT record.
2329 Return TRUE on success, FALSE on error. */
2332 _bfd_vms_slurp_etbt (bfd
*abfd
)
2334 vms_debug2 ((2, "ETBT\n"));
2336 abfd
->flags
|= HAS_LINENO
;
2338 return vms_slurp_debug (abfd
);
2341 /* Process EEOM record.
2342 Return TRUE on success, FALSE on error. */
2345 _bfd_vms_slurp_eeom (bfd
*abfd
)
2347 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2349 vms_debug2 ((2, "EEOM\n"));
2351 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2352 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2353 if (PRIV (eom_data
).eom_w_comcod
> 1)
2355 (*_bfd_error_handler
) (_("Object module NOT error-free !\n"));
2356 bfd_set_error (bfd_error_bad_value
);
2360 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2361 if (PRIV (recrd
.rec_size
) > 10)
2363 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2364 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2365 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2366 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2368 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2373 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2376 _bfd_vms_slurp_object_records (bfd
* abfd
)
2383 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2385 type
= _bfd_vms_get_object_record (abfd
);
2388 vms_debug2 ((2, "next_record failed\n"));
2395 err
= _bfd_vms_slurp_ehdr (abfd
);
2398 err
= _bfd_vms_slurp_eeom (abfd
);
2401 err
= _bfd_vms_slurp_egsd (abfd
);
2404 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2407 err
= _bfd_vms_slurp_edbg (abfd
);
2410 err
= _bfd_vms_slurp_etbt (abfd
);
2417 vms_debug2 ((2, "slurp type %d failed\n", type
));
2421 while (type
!= EOBJ__C_EEOM
);
2426 /* Initialize private data */
2428 vms_initialize (bfd
* abfd
)
2432 amt
= sizeof (struct vms_private_data_struct
);
2433 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2434 if (abfd
->tdata
.any
== NULL
)
2437 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2439 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2440 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2441 if (PRIV (stack
) == NULL
)
2447 bfd_release (abfd
, abfd
->tdata
.any
);
2448 abfd
->tdata
.any
= NULL
;
2452 /* Check the format for a file being read.
2453 Return a (bfd_target *) if it's an object file or zero if not. */
2455 static const struct bfd_target
*
2456 alpha_vms_object_p (bfd
*abfd
)
2458 void *tdata_save
= abfd
->tdata
.any
;
2459 unsigned int test_len
;
2462 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2464 /* Allocate alpha-vms specific data. */
2465 if (!vms_initialize (abfd
))
2468 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2469 goto err_wrong_format
;
2471 /* The first challenge with VMS is to discover the kind of the file.
2473 Image files (executable or shared images) are stored as a raw
2474 stream of bytes (like on UNIX), but there is no magic number.
2476 Object files are written with RMS (record management service), ie
2477 each records are preceeded by its length (on a word - 2 bytes), and
2478 padded for word-alignment. That would be simple but when files
2479 are transfered to a UNIX filesystem (using ftp), records are lost.
2480 Only the raw content of the records are transfered. Fortunately,
2481 the Alpha Object file format also store the length of the record
2482 in the records. Is that clear ? */
2484 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2485 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2486 4 bytes minor id, 4 bytes length). */
2489 /* Size the main buffer. */
2490 buf
= (unsigned char *) bfd_malloc (test_len
);
2493 PRIV (recrd
.buf
) = buf
;
2494 PRIV (recrd
.buf_size
) = test_len
;
2496 /* Initialize the record pointer. */
2497 PRIV (recrd
.rec
) = buf
;
2499 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2500 goto err_wrong_format
;
2502 /* Is it an image? */
2503 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2504 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2506 unsigned int to_read
;
2507 unsigned int read_so_far
;
2508 unsigned int remaining
;
2509 unsigned int eisd_offset
, eihs_offset
;
2511 /* Extract the header size. */
2512 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2514 /* The header size is 0 for DSF files. */
2515 if (PRIV (recrd
.rec_size
) == 0)
2516 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2518 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2520 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2524 PRIV (recrd
.buf
) = NULL
;
2527 PRIV (recrd
.buf
) = buf
;
2528 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2531 /* Read the remaining record. */
2532 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2533 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2534 read_so_far
= test_len
;
2536 while (remaining
> 0)
2538 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2539 goto err_wrong_format
;
2541 read_so_far
+= to_read
;
2542 remaining
-= to_read
;
2544 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2547 /* Reset the record pointer. */
2548 PRIV (recrd
.rec
) = buf
;
2550 /* PR 17512: file: 7d7c57c2. */
2551 if (PRIV (recrd
.rec_size
) < sizeof (struct vms_eihd
))
2553 vms_debug2 ((2, "file type is image\n"));
2555 if (_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
) != TRUE
)
2556 goto err_wrong_format
;
2558 if (_bfd_vms_slurp_eisd (abfd
, eisd_offset
) != TRUE
)
2559 goto err_wrong_format
;
2561 /* EIHS is optional. */
2562 if (eihs_offset
!= 0 && _bfd_vms_slurp_eihs (abfd
, eihs_offset
) != TRUE
)
2563 goto err_wrong_format
;
2569 /* Assume it's a module and adjust record pointer if necessary. */
2570 maybe_adjust_record_pointer_for_object (abfd
);
2572 /* But is it really a module? */
2573 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2574 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2576 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2577 goto err_wrong_format
;
2579 vms_debug2 ((2, "file type is module\n"));
2581 type
= bfd_getl16 (PRIV (recrd
.rec
));
2582 if (type
!= EOBJ__C_EMH
|| _bfd_vms_slurp_ehdr (abfd
) != TRUE
)
2583 goto err_wrong_format
;
2585 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
2586 goto err_wrong_format
;
2589 goto err_wrong_format
;
2592 /* Set arch_info to alpha. */
2594 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2595 goto err_wrong_format
;
2600 bfd_set_error (bfd_error_wrong_format
);
2603 if (PRIV (recrd
.buf
))
2604 free (PRIV (recrd
.buf
));
2605 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2606 bfd_release (abfd
, abfd
->tdata
.any
);
2607 abfd
->tdata
.any
= tdata_save
;
2613 /* Write an EMH/MHD record. */
2616 _bfd_vms_write_emh (bfd
*abfd
)
2618 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2620 _bfd_vms_output_alignment (recwr
, 2);
2623 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2624 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2625 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2626 _bfd_vms_output_long (recwr
, 0);
2627 _bfd_vms_output_long (recwr
, 0);
2628 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2630 /* Create module name from filename. */
2631 if (bfd_get_filename (abfd
) != 0)
2633 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2634 _bfd_vms_output_counted (recwr
, module
);
2638 _bfd_vms_output_counted (recwr
, "NONAME");
2640 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2641 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2642 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2643 _bfd_vms_output_end (abfd
, recwr
);
2646 /* Write an EMH/LMN record. */
2649 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2652 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2653 unsigned int ver
= BFD_VERSION
/ 10000;
2656 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2657 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2658 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2659 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2660 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2661 _bfd_vms_output_end (abfd
, recwr
);
2665 /* Write eom record for bfd abfd. Return FALSE on error. */
2668 _bfd_vms_write_eeom (bfd
*abfd
)
2670 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2672 vms_debug2 ((2, "vms_write_eeom\n"));
2674 _bfd_vms_output_alignment (recwr
, 2);
2676 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2677 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2678 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2679 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2681 if ((abfd
->flags
& EXEC_P
) == 0
2682 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2686 section
= bfd_get_section_by_name (abfd
, ".link");
2689 bfd_set_error (bfd_error_nonrepresentable_section
);
2692 _bfd_vms_output_short (recwr
, 0);
2693 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2694 _bfd_vms_output_long (recwr
,
2695 (unsigned long) bfd_get_start_address (abfd
));
2696 _bfd_vms_output_long (recwr
, 0);
2699 _bfd_vms_output_end (abfd
, recwr
);
2704 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2706 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2709 if (vec
->max_el
== 0)
2712 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2717 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2721 /* Bump ABFD file position to next block. */
2724 alpha_vms_file_position_block (bfd
*abfd
)
2727 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2728 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2731 /* Convert from internal structure SRC to external structure DST. */
2734 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2735 struct vms_eisd
*dst
)
2737 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2738 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2739 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2740 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2742 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2743 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2744 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2745 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2746 dst
->pfc
= src
->u
.eisd
.pfc
;
2747 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2748 dst
->type
= src
->u
.eisd
.type
;
2750 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2752 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2753 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2754 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2758 /* Append EISD to the list of extra eisd for ABFD. */
2761 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2764 if (PRIV (gbl_eisd_head
) == NULL
)
2765 PRIV (gbl_eisd_head
) = eisd
;
2767 PRIV (gbl_eisd_tail
)->next
= eisd
;
2768 PRIV (gbl_eisd_tail
) = eisd
;
2771 /* Create an EISD for shared image SHRIMG.
2772 Return FALSE in case of error. */
2775 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2777 struct vms_internal_eisd_map
*eisd
;
2780 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2781 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2787 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2791 /* Fill the fields. */
2792 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2793 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2794 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2795 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2796 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2797 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2798 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2799 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2800 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2801 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2803 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2804 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2805 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2807 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2809 /* Append it to the list. */
2810 alpha_vms_append_extra_eisd (abfd
, eisd
);
2815 /* Create an EISD for section SEC.
2816 Return FALSE in case of failure. */
2819 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2821 struct vms_internal_eisd_map
*eisd
;
2823 /* Only for allocating section. */
2824 if (!(sec
->flags
& SEC_ALLOC
))
2827 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2828 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2831 vms_section_data (sec
)->eisd
= eisd
;
2833 /* Fill the fields. */
2834 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2835 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2836 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2837 eisd
->u
.eisd
.secsize
=
2838 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2839 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2840 eisd
->u
.eisd
.flags
= 0;
2841 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2842 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2843 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2844 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2846 if (sec
->flags
& SEC_CODE
)
2847 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2848 if (!(sec
->flags
& SEC_READONLY
))
2849 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2851 /* If relocations or fixup will be applied, make this isect writeable. */
2852 if (sec
->flags
& SEC_RELOC
)
2853 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2855 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
2857 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
2858 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
2860 if (sec
->flags
& SEC_LINKER_CREATED
)
2862 if (strcmp (sec
->name
, "$FIXUP$") == 0)
2863 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
2866 /* Append it to the list. */
2868 if (PRIV (eisd_head
) == NULL
)
2869 PRIV (eisd_head
) = eisd
;
2871 PRIV (eisd_tail
)->next
= eisd
;
2872 PRIV (eisd_tail
) = eisd
;
2877 /* Layout executable ABFD and write it to the disk.
2878 Return FALSE in case of failure. */
2881 alpha_vms_write_exec (bfd
*abfd
)
2883 struct vms_eihd eihd
;
2884 struct vms_eiha
*eiha
;
2885 struct vms_eihi
*eihi
;
2886 struct vms_eihs
*eihs
= NULL
;
2888 struct vms_internal_eisd_map
*first_eisd
;
2889 struct vms_internal_eisd_map
*eisd
;
2892 file_ptr gst_filepos
= 0;
2893 unsigned int lnkflags
= 0;
2895 /* Build the EIHD. */
2896 PRIV (file_pos
) = EIHD__C_LENGTH
;
2898 memset (&eihd
, 0, sizeof (eihd
));
2899 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
2901 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
2902 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
2904 bfd_putl32 (sizeof (eihd
), eihd
.size
);
2905 bfd_putl32 (0, eihd
.isdoff
);
2906 bfd_putl32 (0, eihd
.activoff
);
2907 bfd_putl32 (0, eihd
.symdbgoff
);
2908 bfd_putl32 (0, eihd
.imgidoff
);
2909 bfd_putl32 (0, eihd
.patchoff
);
2910 bfd_putl64 (0, eihd
.iafva
);
2911 bfd_putl32 (0, eihd
.version_array_off
);
2913 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
2914 bfd_putl32 (0, eihd
.subtype
);
2916 bfd_putl32 (0, eihd
.imgiocnt
);
2917 bfd_putl32 (-1, eihd
.privreqs
);
2918 bfd_putl32 (-1, eihd
.privreqs
+ 4);
2920 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2922 bfd_putl32 (0, eihd
.ident
);
2923 bfd_putl32 (0, eihd
.sysver
);
2926 bfd_putl32 (0, eihd
.symvect_size
);
2927 bfd_putl32 (16, eihd
.virt_mem_block_size
);
2928 bfd_putl32 (0, eihd
.ext_fixup_off
);
2929 bfd_putl32 (0, eihd
.noopt_psect_off
);
2930 bfd_putl32 (-1, eihd
.alias
);
2933 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
2934 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
2935 PRIV (file_pos
) += sizeof (struct vms_eiha
);
2937 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
2938 bfd_putl32 (0, eiha
->spare
);
2939 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
2940 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
2941 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
2942 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
2943 bfd_putl64 (0, eiha
->inishr
);
2946 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
2947 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
2948 PRIV (file_pos
) += sizeof (struct vms_eihi
);
2950 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
2951 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
2956 /* Set module name. */
2957 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2958 len
= strlen (module
);
2959 if (len
> sizeof (eihi
->imgnam
) - 1)
2960 len
= sizeof (eihi
->imgnam
) - 1;
2961 eihi
->imgnam
[0] = len
;
2962 memcpy (eihi
->imgnam
+ 1, module
, len
);
2970 vms_get_time (&hi
, &lo
);
2971 bfd_putl32 (lo
, eihi
->linktime
+ 0);
2972 bfd_putl32 (hi
, eihi
->linktime
+ 4);
2975 eihi
->linkid
[0] = 0;
2976 eihi
->imgbid
[0] = 0;
2979 dst
= PRIV (dst_section
);
2980 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
2981 if (dst
!= NULL
&& dst
->size
!= 0)
2983 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
2984 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
2985 PRIV (file_pos
) += sizeof (struct vms_eihs
);
2987 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
2988 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
2989 bfd_putl32 (0, eihs
->dstvbn
);
2990 bfd_putl32 (0, eihs
->dstsize
);
2991 bfd_putl32 (0, eihs
->gstvbn
);
2992 bfd_putl32 (0, eihs
->gstsize
);
2993 bfd_putl32 (0, eihs
->dmtvbn
);
2994 bfd_putl32 (0, eihs
->dmtsize
);
2997 /* One EISD per section. */
2998 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3000 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3004 /* Merge section EIDS which extra ones. */
3005 if (PRIV (eisd_tail
))
3006 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3008 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3009 if (PRIV (gbl_eisd_tail
))
3010 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3012 first_eisd
= PRIV (eisd_head
);
3014 /* Add end of eisd. */
3017 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3020 eisd
->u
.eisd
.majorid
= 0;
3021 eisd
->u
.eisd
.minorid
= 0;
3022 eisd
->u
.eisd
.eisdsize
= 0;
3023 alpha_vms_append_extra_eisd (abfd
, eisd
);
3026 /* Place EISD in the file. */
3027 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3029 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3031 /* First block is a little bit special: there is a word at the end. */
3032 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3034 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3035 alpha_vms_file_position_block (abfd
);
3037 eisd
->file_pos
= PRIV (file_pos
);
3038 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3040 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3041 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3044 if (first_eisd
!= NULL
)
3046 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3047 /* Real size of end of eisd marker. */
3048 PRIV (file_pos
) += EISD__K_LENEND
;
3051 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3052 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3055 /* Place sections. */
3056 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3058 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3061 eisd
= vms_section_data (sec
)->eisd
;
3063 /* Align on a block. */
3064 alpha_vms_file_position_block (abfd
);
3065 sec
->filepos
= PRIV (file_pos
);
3068 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3070 PRIV (file_pos
) += sec
->size
;
3074 if (eihs
!= NULL
&& dst
!= NULL
)
3076 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3077 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3081 lnkflags
|= EIHD__M_DBGDMT
;
3082 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3083 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3085 if (PRIV (gsd_sym_count
) != 0)
3087 alpha_vms_file_position_block (abfd
);
3088 gst_filepos
= PRIV (file_pos
);
3089 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3090 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3094 /* Write EISD in hdr. */
3095 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3097 alpha_vms_swap_eisd_out
3098 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3100 /* Write first block. */
3101 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3102 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3105 /* Write remaining eisd. */
3108 unsigned char blk
[VMS_BLOCK_SIZE
];
3109 struct vms_internal_eisd_map
*next_eisd
;
3111 memset (blk
, 0xff, sizeof (blk
));
3112 while (eisd
!= NULL
)
3114 alpha_vms_swap_eisd_out
3116 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3118 next_eisd
= eisd
->next
;
3119 if (next_eisd
== NULL
3120 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3121 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3123 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3126 memset (blk
, 0xff, sizeof (blk
));
3132 /* Write sections. */
3133 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3135 unsigned char blk
[VMS_BLOCK_SIZE
];
3138 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3140 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3144 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3145 if (len
!= VMS_BLOCK_SIZE
)
3147 memset (blk
, 0, len
);
3148 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3154 if (gst_filepos
!= 0)
3156 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3159 _bfd_vms_write_emh (abfd
);
3160 _bfd_vms_write_lmn (abfd
, "GNU LD");
3162 /* PSC for the absolute section. */
3163 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3164 _bfd_vms_output_long (recwr
, 0);
3165 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3166 _bfd_vms_output_short (recwr
, 0);
3167 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3168 _bfd_vms_output_long (recwr
, 0);
3169 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3170 _bfd_vms_output_end_subrec (recwr
);
3171 _bfd_vms_output_end (abfd
, recwr
);
3173 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3175 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3181 _bfd_vms_output_alignment (recwr
, 8);
3182 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3183 _bfd_vms_output_long (recwr
, 0);
3185 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3186 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3187 _bfd_vms_output_short (recwr
, sym
->flags
);
3189 if (sym
->code_section
)
3190 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3193 BFD_ASSERT (sym
->code_value
== 0);
3196 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3197 _bfd_vms_output_quad
3198 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3199 _bfd_vms_output_quad (recwr
, ep
);
3200 _bfd_vms_output_quad (recwr
, val
);
3201 _bfd_vms_output_long (recwr
, 0);
3202 _bfd_vms_output_counted (recwr
, sym
->name
);
3203 _bfd_vms_output_end_subrec (recwr
);
3205 _bfd_vms_output_end (abfd
, recwr
);
3208 _bfd_vms_output_end (abfd
, recwr
);
3210 if (!_bfd_vms_write_eeom (abfd
))
3218 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3221 _bfd_vms_write_egsd (bfd
*abfd
)
3225 unsigned int symnum
;
3227 flagword new_flags
, old_flags
;
3228 int abs_section_index
= -1;
3229 unsigned int target_index
= 0;
3230 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3232 vms_debug2 ((2, "vms_write_egsd\n"));
3234 /* Egsd is quadword aligned. */
3235 _bfd_vms_output_alignment (recwr
, 8);
3237 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3238 _bfd_vms_output_long (recwr
, 0);
3240 /* Number sections. */
3241 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3243 if (section
->flags
& SEC_DEBUGGING
)
3245 if (!strcmp (section
->name
, ".vmsdebug"))
3247 section
->flags
|= SEC_DEBUGGING
;
3250 section
->target_index
= target_index
++;
3253 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3255 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3256 section
->target_index
, section
->name
, (int)section
->size
));
3258 /* Don't write out the VMS debug info section since it is in the
3259 ETBT and EDBG sections in etir. */
3260 if (section
->flags
& SEC_DEBUGGING
)
3263 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3264 if (_bfd_vms_output_check (recwr
, 64) < 0)
3266 _bfd_vms_output_end (abfd
, recwr
);
3267 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3268 _bfd_vms_output_long (recwr
, 0);
3271 /* Don't know if this is necessary for the linker but for now it keeps
3272 vms_slurp_gsd happy. */
3273 sname
= section
->name
;
3276 /* Remove leading dot. */
3278 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3279 sname
= EVAX_CODE_NAME
;
3280 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3281 sname
= EVAX_DATA_NAME
;
3282 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3283 sname
= EVAX_BSS_NAME
;
3284 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3285 sname
= EVAX_LINK_NAME
;
3286 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3287 sname
= EVAX_READONLY_NAME
;
3288 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3289 sname
= EVAX_LITERAL_NAME
;
3290 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3291 sname
= EVAX_LITERALS_NAME
;
3292 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3293 sname
= EVAX_COMMON_NAME
;
3294 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3295 sname
= EVAX_LOCAL_NAME
;
3298 if (bfd_is_com_section (section
))
3299 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3300 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3302 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3305 /* Modify them as directed. */
3306 if (section
->flags
& SEC_READONLY
)
3307 new_flags
&= ~EGPS__V_WRT
;
3309 new_flags
&= ~vms_section_data (section
)->no_flags
;
3310 new_flags
|= vms_section_data (section
)->flags
;
3312 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3313 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3314 new_flags
, (unsigned long)section
->size
));
3316 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3317 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3318 _bfd_vms_output_short (recwr
, new_flags
);
3319 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3320 _bfd_vms_output_counted (recwr
, sname
);
3321 _bfd_vms_output_end_subrec (recwr
);
3323 /* If the section is an obsolute one, remind its index as it will be
3324 used later for absolute symbols. */
3325 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3326 abs_section_index
= section
->target_index
;
3329 /* Output symbols. */
3330 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3332 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3334 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3336 symbol
= abfd
->outsymbols
[symnum
];
3337 old_flags
= symbol
->flags
;
3339 /* Work-around a missing feature: consider __main as the main entry
3341 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3342 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3344 /* Only put in the GSD the global and the undefined symbols. */
3345 if (old_flags
& BSF_FILE
)
3348 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3350 /* If the LIB$INITIIALIZE section is present, add a reference to
3351 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3352 in the assembly file. */
3353 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3354 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3358 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3359 bytes for a possible ABS section. */
3360 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3362 _bfd_vms_output_end (abfd
, recwr
);
3363 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3364 _bfd_vms_output_long (recwr
, 0);
3367 if ((old_flags
& BSF_GLOBAL
) != 0
3368 && bfd_is_abs_section (symbol
->section
)
3369 && abs_section_index
<= 0)
3371 /* Create an absolute section if none was defined. It is highly
3372 unlikely that the name $ABS$ clashes with a user defined
3373 non-absolute section name. */
3374 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3375 _bfd_vms_output_short (recwr
, 4);
3376 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3377 _bfd_vms_output_long (recwr
, 0);
3378 _bfd_vms_output_counted (recwr
, "$ABS$");
3379 _bfd_vms_output_end_subrec (recwr
);
3381 abs_section_index
= target_index
++;
3384 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3386 /* Data type, alignment. */
3387 _bfd_vms_output_short (recwr
, 0);
3391 if (old_flags
& BSF_WEAK
)
3392 new_flags
|= EGSY__V_WEAK
;
3393 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3394 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3396 if (old_flags
& BSF_FUNCTION
)
3398 new_flags
|= EGSY__V_NORM
;
3399 new_flags
|= EGSY__V_REL
;
3401 if (old_flags
& BSF_GLOBAL
)
3403 new_flags
|= EGSY__V_DEF
;
3404 if (!bfd_is_abs_section (symbol
->section
))
3405 new_flags
|= EGSY__V_REL
;
3407 _bfd_vms_output_short (recwr
, new_flags
);
3409 if (old_flags
& BSF_GLOBAL
)
3411 /* Symbol definition. */
3412 bfd_vma code_address
= 0;
3413 unsigned long ca_psindx
= 0;
3414 unsigned long psindx
;
3416 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3421 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3422 code_address
= sym
->value
;
3423 ca_psindx
= sym
->section
->target_index
;
3425 if (bfd_is_abs_section (symbol
->section
))
3426 psindx
= abs_section_index
;
3428 psindx
= symbol
->section
->target_index
;
3430 _bfd_vms_output_quad (recwr
, symbol
->value
);
3431 _bfd_vms_output_quad (recwr
, code_address
);
3432 _bfd_vms_output_long (recwr
, ca_psindx
);
3433 _bfd_vms_output_long (recwr
, psindx
);
3435 _bfd_vms_output_counted (recwr
, symbol
->name
);
3437 _bfd_vms_output_end_subrec (recwr
);
3440 _bfd_vms_output_alignment (recwr
, 8);
3441 _bfd_vms_output_end (abfd
, recwr
);
3446 /* Write object header for bfd abfd. Return FALSE on error. */
3449 _bfd_vms_write_ehdr (bfd
*abfd
)
3452 unsigned int symnum
;
3453 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3455 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3457 _bfd_vms_output_alignment (recwr
, 2);
3459 _bfd_vms_write_emh (abfd
);
3460 _bfd_vms_write_lmn (abfd
, "GNU AS");
3463 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3464 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3466 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3468 symbol
= abfd
->outsymbols
[symnum
];
3470 if (symbol
->flags
& BSF_FILE
)
3472 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3473 (int) strlen (symbol
->name
));
3478 if (symnum
== abfd
->symcount
)
3479 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3481 _bfd_vms_output_end (abfd
, recwr
);
3484 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3485 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3486 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3487 _bfd_vms_output_end (abfd
, recwr
);
3490 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3491 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3492 _bfd_vms_output_dump (recwr
,
3493 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3495 _bfd_vms_output_end (abfd
, recwr
);
3500 /* Part 4.6, relocations. */
3503 /* WRITE ETIR SECTION
3505 This is still under construction and therefore not documented. */
3507 /* Close the etir/etbt record. */
3510 end_etir_record (bfd
* abfd
)
3512 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3514 _bfd_vms_output_end (abfd
, recwr
);
3518 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3520 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3522 if (section
->flags
& SEC_DEBUGGING
)
3524 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3528 /* Push start offset. */
3529 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3530 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3531 _bfd_vms_output_end_subrec (recwr
);
3534 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3535 _bfd_vms_output_end_subrec (recwr
);
3540 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3544 /* Push start offset. */
3545 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3546 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3547 _bfd_vms_output_quad (recwr
, offset
);
3548 _bfd_vms_output_end_subrec (recwr
);
3550 /* Start = pop (). */
3551 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3552 _bfd_vms_output_end_subrec (recwr
);
3557 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3558 address VADDR in section specified by SEC_INDEX and NAME. */
3561 sto_imm (bfd
*abfd
, asection
*section
,
3562 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3565 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3568 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3569 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3574 /* Try all the rest. */
3577 if (_bfd_vms_output_check (recwr
, size
) < 0)
3579 /* Doesn't fit, split ! */
3580 end_etir_record (abfd
);
3582 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3584 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3585 if (size
> ssize
) /* more than what's left ? */
3589 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3590 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3591 _bfd_vms_output_dump (recwr
, cptr
, size
);
3592 _bfd_vms_output_end_subrec (recwr
);
3595 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3596 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3606 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3608 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3610 /* Not enough room in this record. Close it and open a new one. */
3611 end_etir_record (abfd
);
3612 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3616 /* Return whether RELOC must be deferred till the end. */
3619 defer_reloc_p (arelent
*reloc
)
3621 switch (reloc
->howto
->type
)
3634 /* Write section contents for bfd abfd. Return FALSE on error. */
3637 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3640 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3642 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3644 _bfd_vms_output_alignment (recwr
, 4);
3646 PRIV (vms_linkage_index
) = 0;
3648 for (section
= abfd
->sections
; section
; section
= section
->next
)
3650 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3651 section
->target_index
, section
->name
, (int) (section
->size
)));
3653 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3654 || bfd_is_com_section (section
))
3657 if (!section
->contents
)
3659 bfd_set_error (bfd_error_no_contents
);
3663 start_etir_or_etbt_record (abfd
, section
, 0);
3665 if (section
->flags
& SEC_RELOC
)
3667 bfd_vma curr_addr
= 0;
3668 unsigned char *curr_data
= section
->contents
;
3670 int pass2_needed
= 0;
3671 int pass2_in_progress
= 0;
3674 if (section
->reloc_count
== 0)
3675 (*_bfd_error_handler
)
3676 (_("SEC_RELOC with no relocs in section %s"), section
->name
);
3681 int i
= section
->reloc_count
;
3682 arelent
**rptr
= section
->orelocation
;
3683 _bfd_vms_debug (4, "%d relocations:\n", i
);
3686 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3687 "addr %08lx, off %08lx, len %d: %s\n",
3688 (*(*rptr
)->sym_ptr_ptr
)->name
,
3689 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3690 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3691 (unsigned long)(*rptr
)->address
,
3692 (unsigned long)(*rptr
)->addend
,
3693 bfd_get_reloc_size ((*rptr
)->howto
),
3694 ( *rptr
)->howto
->name
);
3701 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3703 struct evax_private_udata_struct
*udata
;
3704 arelent
*rptr
= section
->orelocation
[irel
];
3705 bfd_vma addr
= rptr
->address
;
3706 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3707 asection
*sec
= sym
->section
;
3708 bfd_boolean defer
= defer_reloc_p (rptr
);
3711 if (pass2_in_progress
)
3713 /* Non-deferred relocs have already been output. */
3719 /* Deferred relocs must be output at the very end. */
3726 /* Regular relocs are intertwined with binary data. */
3727 if (curr_addr
> addr
)
3728 (*_bfd_error_handler
) (_("Size error in section %s"),
3730 size
= addr
- curr_addr
;
3731 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3736 size
= bfd_get_reloc_size (rptr
->howto
);
3738 switch (rptr
->howto
->type
)
3740 case ALPHA_R_IGNORE
:
3743 case ALPHA_R_REFLONG
:
3744 if (bfd_is_und_section (sym
->section
))
3746 bfd_vma addend
= rptr
->addend
;
3747 slen
= strlen ((char *) sym
->name
);
3748 etir_output_check (abfd
, section
, curr_addr
, slen
);
3751 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3752 _bfd_vms_output_counted (recwr
, sym
->name
);
3753 _bfd_vms_output_end_subrec (recwr
);
3754 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3755 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3756 _bfd_vms_output_end_subrec (recwr
);
3757 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3758 _bfd_vms_output_end_subrec (recwr
);
3759 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3760 _bfd_vms_output_end_subrec (recwr
);
3764 _bfd_vms_output_begin_subrec
3765 (recwr
, ETIR__C_STO_GBL_LW
);
3766 _bfd_vms_output_counted (recwr
, sym
->name
);
3767 _bfd_vms_output_end_subrec (recwr
);
3770 else if (bfd_is_abs_section (sym
->section
))
3772 etir_output_check (abfd
, section
, curr_addr
, 16);
3773 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3774 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3775 _bfd_vms_output_end_subrec (recwr
);
3776 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3777 _bfd_vms_output_end_subrec (recwr
);
3781 etir_output_check (abfd
, section
, curr_addr
, 32);
3782 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3783 _bfd_vms_output_long (recwr
,
3784 (unsigned long) sec
->target_index
);
3785 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3786 _bfd_vms_output_end_subrec (recwr
);
3787 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3788 says that we should have a ETIR__C_STO_OFF here.
3789 But the relocation would not be BFD_RELOC_32 then.
3790 This case is very likely unreachable. */
3791 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3792 _bfd_vms_output_end_subrec (recwr
);
3796 case ALPHA_R_REFQUAD
:
3797 if (bfd_is_und_section (sym
->section
))
3799 bfd_vma addend
= rptr
->addend
;
3800 slen
= strlen ((char *) sym
->name
);
3801 etir_output_check (abfd
, section
, curr_addr
, slen
);
3804 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3805 _bfd_vms_output_counted (recwr
, sym
->name
);
3806 _bfd_vms_output_end_subrec (recwr
);
3807 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3808 _bfd_vms_output_quad (recwr
, addend
);
3809 _bfd_vms_output_end_subrec (recwr
);
3810 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3811 _bfd_vms_output_end_subrec (recwr
);
3812 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3813 _bfd_vms_output_end_subrec (recwr
);
3817 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3818 _bfd_vms_output_counted (recwr
, sym
->name
);
3819 _bfd_vms_output_end_subrec (recwr
);
3822 else if (bfd_is_abs_section (sym
->section
))
3824 etir_output_check (abfd
, section
, curr_addr
, 16);
3825 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3826 _bfd_vms_output_quad (recwr
, sym
->value
);
3827 _bfd_vms_output_end_subrec (recwr
);
3828 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3829 _bfd_vms_output_end_subrec (recwr
);
3833 etir_output_check (abfd
, section
, curr_addr
, 32);
3834 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3835 _bfd_vms_output_long (recwr
,
3836 (unsigned long) sec
->target_index
);
3837 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3838 _bfd_vms_output_end_subrec (recwr
);
3839 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3840 _bfd_vms_output_end_subrec (recwr
);
3845 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3848 case ALPHA_R_LINKAGE
:
3849 etir_output_check (abfd
, section
, curr_addr
, 64);
3850 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
3851 _bfd_vms_output_long
3852 (recwr
, (unsigned long) rptr
->addend
);
3853 if (rptr
->addend
> PRIV (vms_linkage_index
))
3854 PRIV (vms_linkage_index
) = rptr
->addend
;
3855 _bfd_vms_output_counted (recwr
, sym
->name
);
3856 _bfd_vms_output_byte (recwr
, 0);
3857 _bfd_vms_output_end_subrec (recwr
);
3860 case ALPHA_R_CODEADDR
:
3861 slen
= strlen ((char *) sym
->name
);
3862 etir_output_check (abfd
, section
, curr_addr
, slen
);
3863 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
3864 _bfd_vms_output_counted (recwr
, sym
->name
);
3865 _bfd_vms_output_end_subrec (recwr
);
3870 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3871 etir_output_check (abfd
, section
, curr_addr
,
3872 32 + 1 + strlen (udata
->origname
));
3873 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
3874 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3875 _bfd_vms_output_long
3876 (recwr
, (unsigned long) section
->target_index
);
3877 _bfd_vms_output_quad (recwr
, rptr
->address
);
3878 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
3879 _bfd_vms_output_long
3880 (recwr
, (unsigned long) section
->target_index
);
3881 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3882 _bfd_vms_output_counted (recwr
, udata
->origname
);
3883 _bfd_vms_output_end_subrec (recwr
);
3887 (*_bfd_error_handler
) (_("Spurious ALPHA_R_BSR reloc"));
3892 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3893 etir_output_check (abfd
, section
, curr_addr
,
3894 32 + 1 + strlen (udata
->origname
));
3895 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
3896 _bfd_vms_output_long
3897 (recwr
, (unsigned long) udata
->lkindex
+ 1);
3898 _bfd_vms_output_long
3899 (recwr
, (unsigned long) section
->target_index
);
3900 _bfd_vms_output_quad (recwr
, rptr
->address
);
3901 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
3902 _bfd_vms_output_long
3903 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
3904 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3905 _bfd_vms_output_counted (recwr
, udata
->origname
);
3906 _bfd_vms_output_end_subrec (recwr
);
3911 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3912 etir_output_check (abfd
, section
, curr_addr
,
3913 32 + 1 + strlen (udata
->origname
));
3914 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
3915 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3916 _bfd_vms_output_long
3917 (recwr
, (unsigned long) section
->target_index
);
3918 _bfd_vms_output_quad (recwr
, rptr
->address
);
3919 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
3920 _bfd_vms_output_long
3921 (recwr
, (unsigned long) section
->target_index
);
3922 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3923 _bfd_vms_output_counted (recwr
, udata
->origname
);
3924 _bfd_vms_output_end_subrec (recwr
);
3928 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
3935 } /* End of relocs loop. */
3937 if (!pass2_in_progress
)
3939 /* Output rest of section. */
3940 if (curr_addr
> section
->size
)
3941 (*_bfd_error_handler
) (_("Size error in section %s"),
3943 size
= section
->size
- curr_addr
;
3944 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3950 pass2_in_progress
= 1;
3956 else /* (section->flags & SEC_RELOC) */
3957 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
3959 end_etir_record (abfd
);
3962 _bfd_vms_output_alignment (recwr
, 2);
3966 /* Write cached information into a file being written, at bfd_close. */
3969 alpha_vms_write_object_contents (bfd
*abfd
)
3971 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
3973 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3975 return alpha_vms_write_exec (abfd
);
3979 if (abfd
->section_count
> 0) /* we have sections */
3981 if (_bfd_vms_write_ehdr (abfd
) != TRUE
)
3983 if (_bfd_vms_write_egsd (abfd
) != TRUE
)
3985 if (_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
) != TRUE
)
3987 if (_bfd_vms_write_eeom (abfd
) != TRUE
)
3994 /* Debug stuff: nearest line. */
3996 #define SET_MODULE_PARSED(m) \
3997 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
3998 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4000 /* Build a new module for the specified BFD. */
4002 static struct module
*
4003 new_module (bfd
*abfd
)
4005 struct module
*module
4006 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4007 module
->file_table_count
= 16; /* Arbitrary. */
4009 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4013 /* Parse debug info for a module and internalize it. */
4016 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4019 unsigned char *maxptr
= ptr
+ length
;
4020 unsigned char *src_ptr
, *pcl_ptr
;
4021 unsigned int prev_linum
= 0, curr_linenum
= 0;
4022 bfd_vma prev_pc
= 0, curr_pc
= 0;
4023 struct srecinfo
*curr_srec
, *srec
;
4024 struct lineinfo
*curr_line
, *line
;
4025 struct funcinfo
*funcinfo
;
4027 /* Initialize tables with zero element. */
4028 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4029 module
->srec_table
= curr_srec
;
4031 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4032 module
->line_table
= curr_line
;
4034 while (length
== -1 || ptr
< maxptr
)
4036 /* The first byte is not counted in the recorded length. */
4037 int rec_length
= bfd_getl16 (ptr
) + 1;
4038 int rec_type
= bfd_getl16 (ptr
+ 2);
4040 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4042 if (length
== -1 && rec_type
== DST__K_MODEND
)
4049 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
);
4056 vms_debug2 ((3, "module: %s\n", module
->name
));
4063 funcinfo
= (struct funcinfo
*)
4064 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4066 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
);
4067 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4068 funcinfo
->next
= module
->func_table
;
4069 module
->func_table
= funcinfo
;
4071 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4072 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4076 module
->func_table
->high
= module
->func_table
->low
4077 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4079 if (module
->func_table
->high
> module
->high
)
4080 module
->high
= module
->func_table
->high
;
4082 vms_debug2 ((3, "end routine\n"));
4086 vms_debug2 ((3, "prologue\n"));
4090 vms_debug2 ((3, "epilog\n"));
4094 vms_debug2 ((3, "block\n"));
4098 vms_debug2 ((3, "end block\n"));
4102 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4104 vms_debug2 ((3, "source info\n"));
4106 while (src_ptr
< ptr
+ rec_length
)
4108 int cmd
= src_ptr
[0], cmd_length
, data
;
4112 case DST__K_SRC_DECLFILE
:
4115 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4117 = _bfd_vms_save_counted_string (src_ptr
4118 + DST_S_B_SRC_DF_FILENAME
);
4120 while (fileid
>= module
->file_table_count
)
4122 module
->file_table_count
*= 2;
4124 = bfd_realloc (module
->file_table
,
4125 module
->file_table_count
4126 * sizeof (struct fileinfo
));
4129 module
->file_table
[fileid
].name
= filename
;
4130 module
->file_table
[fileid
].srec
= 1;
4131 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4132 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4133 fileid
, module
->file_table
[fileid
].name
));
4137 case DST__K_SRC_DEFLINES_B
:
4138 /* Perform the association and set the next higher index
4140 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4141 srec
= (struct srecinfo
*)
4142 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4143 srec
->line
= curr_srec
->line
+ data
;
4144 srec
->srec
= curr_srec
->srec
+ data
;
4145 srec
->sfile
= curr_srec
->sfile
;
4146 curr_srec
->next
= srec
;
4149 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4152 case DST__K_SRC_DEFLINES_W
:
4153 /* Perform the association and set the next higher index
4155 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4156 srec
= (struct srecinfo
*)
4157 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4158 srec
->line
= curr_srec
->line
+ data
;
4159 srec
->srec
= curr_srec
->srec
+ data
,
4160 srec
->sfile
= curr_srec
->sfile
;
4161 curr_srec
->next
= srec
;
4164 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4167 case DST__K_SRC_INCRLNUM_B
:
4168 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4169 curr_srec
->line
+= data
;
4171 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4174 case DST__K_SRC_SETFILE
:
4175 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4176 curr_srec
->sfile
= data
;
4177 curr_srec
->srec
= module
->file_table
[data
].srec
;
4179 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4182 case DST__K_SRC_SETLNUM_L
:
4183 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4184 curr_srec
->line
= data
;
4186 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4189 case DST__K_SRC_SETLNUM_W
:
4190 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4191 curr_srec
->line
= data
;
4193 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4196 case DST__K_SRC_SETREC_L
:
4197 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4198 curr_srec
->srec
= data
;
4199 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4201 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4204 case DST__K_SRC_SETREC_W
:
4205 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4206 curr_srec
->srec
= data
;
4207 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4209 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4212 case DST__K_SRC_FORMFEED
:
4214 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4218 (*_bfd_error_handler
) (_("unknown source command %d"),
4224 src_ptr
+= cmd_length
;
4228 case DST__K_LINE_NUM
:
4229 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4231 vms_debug2 ((3, "line info\n"));
4233 while (pcl_ptr
< ptr
+ rec_length
)
4235 /* The command byte is signed so we must sign-extend it. */
4236 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4240 case DST__K_DELTA_PC_W
:
4241 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4245 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4248 case DST__K_DELTA_PC_L
:
4249 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4253 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4256 case DST__K_INCR_LINUM
:
4257 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4258 curr_linenum
+= data
;
4260 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4263 case DST__K_INCR_LINUM_W
:
4264 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4265 curr_linenum
+= data
;
4267 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4270 case DST__K_INCR_LINUM_L
:
4271 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4272 curr_linenum
+= data
;
4274 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4277 case DST__K_SET_LINUM_INCR
:
4278 (*_bfd_error_handler
)
4279 (_("DST__K_SET_LINUM_INCR not implemented"));
4283 case DST__K_SET_LINUM_INCR_W
:
4284 (*_bfd_error_handler
)
4285 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4289 case DST__K_RESET_LINUM_INCR
:
4290 (*_bfd_error_handler
)
4291 (_("DST__K_RESET_LINUM_INCR not implemented"));
4295 case DST__K_BEG_STMT_MODE
:
4296 (*_bfd_error_handler
)
4297 (_("DST__K_BEG_STMT_MODE not implemented"));
4301 case DST__K_END_STMT_MODE
:
4302 (*_bfd_error_handler
)
4303 (_("DST__K_END_STMT_MODE not implemented"));
4307 case DST__K_SET_LINUM_B
:
4308 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4309 curr_linenum
= data
;
4311 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4314 case DST__K_SET_LINUM
:
4315 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4316 curr_linenum
= data
;
4318 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4321 case DST__K_SET_LINUM_L
:
4322 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4323 curr_linenum
= data
;
4325 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4329 (*_bfd_error_handler
)
4330 (_("DST__K_SET_PC not implemented"));
4334 case DST__K_SET_PC_W
:
4335 (*_bfd_error_handler
)
4336 (_("DST__K_SET_PC_W not implemented"));
4340 case DST__K_SET_PC_L
:
4341 (*_bfd_error_handler
)
4342 (_("DST__K_SET_PC_L not implemented"));
4346 case DST__K_SET_STMTNUM
:
4347 (*_bfd_error_handler
)
4348 (_("DST__K_SET_STMTNUM not implemented"));
4353 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4356 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4360 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4363 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4367 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4370 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4373 case DST__K_SET_ABS_PC
:
4374 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4377 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4386 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4387 (unsigned long)curr_pc
, curr_linenum
));
4391 (*_bfd_error_handler
) (_("unknown line command %d"),
4398 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4400 || cmd
== DST__K_DELTA_PC_L
4401 || cmd
== DST__K_DELTA_PC_W
)
4403 line
= (struct lineinfo
*)
4404 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4405 line
->address
= curr_pc
;
4406 line
->line
= curr_linenum
;
4408 curr_line
->next
= line
;
4411 prev_linum
= curr_linenum
;
4413 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4414 (unsigned long)curr_pc
, curr_linenum
));
4417 pcl_ptr
+= cmd_length
;
4421 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4422 vms_debug2 ((3, "undocumented type 0x17\n"));
4426 vms_debug2 ((3, "ignoring record\n"));
4434 /* Finalize tables with EOL marker. */
4435 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4436 srec
->line
= (unsigned int) -1;
4437 srec
->srec
= (unsigned int) -1;
4438 curr_srec
->next
= srec
;
4440 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4441 line
->line
= (unsigned int) -1;
4442 line
->address
= (bfd_vma
) -1;
4443 curr_line
->next
= line
;
4445 /* Advertise that this module has been parsed. This is needed
4446 because parsing can be either performed at module creation
4447 or deferred until debug info is consumed. */
4448 SET_MODULE_PARSED (module
);
4451 /* Build the list of modules for the specified BFD. */
4453 static struct module
*
4454 build_module_list (bfd
*abfd
)
4456 struct module
*module
, *list
= NULL
;
4459 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4461 /* We have a DMT section so this must be an image. Parse the
4462 section and build the list of modules. This is sufficient
4463 since we can compute the start address and the end address
4464 of every module from the section contents. */
4465 bfd_size_type size
= bfd_get_section_size (dmt
);
4466 unsigned char *ptr
, *end
;
4468 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4472 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4475 vms_debug2 ((2, "DMT\n"));
4481 /* Each header declares a module with its start offset and size
4482 of debug info in the DST section, as well as the count of
4483 program sections (i.e. address spans) it contains. */
4484 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4485 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4486 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4487 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4489 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4490 modbeg
, msize
, count
));
4492 /* We create a 'module' structure for each program section since
4493 we only support contiguous addresses in a 'module' structure.
4494 As a consequence, the actual debug info in the DST section is
4495 shared and can be parsed multiple times; that doesn't seem to
4496 cause problems in practice. */
4499 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4500 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4501 module
= new_module (abfd
);
4502 module
->modbeg
= modbeg
;
4503 module
->size
= msize
;
4504 module
->low
= start
;
4505 module
->high
= start
+ length
;
4506 module
->next
= list
;
4508 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4510 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4517 /* We don't have a DMT section so this must be an object. Parse
4518 the module right now in order to compute its start address and
4520 void *dst
= PRIV (dst_section
)->contents
;
4525 module
= new_module (abfd
);
4526 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4533 /* Calculate and return the name of the source file and the line nearest
4534 to the wanted location in the specified module. */
4537 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4538 const char **file
, const char **func
,
4541 struct funcinfo
*funcinfo
;
4542 struct lineinfo
*lineinfo
;
4543 struct srecinfo
*srecinfo
;
4544 bfd_boolean ret
= FALSE
;
4546 /* Parse this module if that was not done at module creation. */
4547 if (! IS_MODULE_PARSED (module
))
4549 unsigned int size
= module
->size
;
4550 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4551 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4553 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4554 || bfd_bread (buffer
, size
, abfd
) != size
)
4556 bfd_set_error (bfd_error_no_debug_section
);
4560 parse_module (abfd
, module
, buffer
, size
);
4564 /* Find out the function (if any) that contains the address. */
4565 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4566 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4568 *func
= funcinfo
->name
;
4573 /* Find out the source file and the line nearest to the address. */
4574 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4575 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4577 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4578 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4580 if (srecinfo
->sfile
> 0)
4582 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4583 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4587 *file
= module
->name
;
4588 *line
= lineinfo
->line
;
4599 /* Provided a BFD, a section and an offset into the section, calculate and
4600 return the name of the source file and the line nearest to the wanted
4604 _bfd_vms_find_nearest_line (bfd
*abfd
,
4605 asymbol
**symbols ATTRIBUTE_UNUSED
,
4611 unsigned int *discriminator
)
4613 struct module
*module
;
4615 /* What address are we looking for? */
4616 bfd_vma addr
= section
->vma
+ offset
;
4624 /* We can't do anything if there is no DST (debug symbol table). */
4625 if (PRIV (dst_section
) == NULL
)
4628 /* Create the module list - if not already done. */
4629 if (PRIV (modules
) == NULL
)
4631 PRIV (modules
) = build_module_list (abfd
);
4632 if (PRIV (modules
) == NULL
)
4636 for (module
= PRIV (modules
); module
; module
= module
->next
)
4637 if (addr
>= module
->low
&& addr
<= module
->high
)
4638 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4643 /* Canonicalizations. */
4644 /* Set name, value, section and flags of SYM from E. */
4647 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4656 flags
= BSF_NO_FLAGS
;
4662 if (e
->flags
& EGSY__V_WEAK
)
4665 if (e
->flags
& EGSY__V_DEF
)
4667 /* Symbol definition. */
4668 flags
|= BSF_GLOBAL
;
4669 if (e
->flags
& EGSY__V_NORM
)
4670 flags
|= BSF_FUNCTION
;
4676 /* Symbol reference. */
4677 sec
= bfd_und_section_ptr
;
4682 /* A universal symbol is by definition global... */
4683 flags
|= BSF_GLOBAL
;
4685 /* ...and dynamic in shared libraries. */
4686 if (abfd
->flags
& DYNAMIC
)
4687 flags
|= BSF_DYNAMIC
;
4689 if (e
->flags
& EGSY__V_WEAK
)
4692 if (!(e
->flags
& EGSY__V_DEF
))
4695 if (e
->flags
& EGSY__V_NORM
)
4696 flags
|= BSF_FUNCTION
;
4699 /* sec = e->section; */
4700 sec
= bfd_abs_section_ptr
;
4715 /* Return the number of bytes required to store a vector of pointers
4716 to asymbols for all the symbols in the BFD abfd, including a
4717 terminal NULL pointer. If there are no symbols in the BFD,
4718 then return 0. If an error occurs, return -1. */
4721 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4723 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4724 abfd
, PRIV (gsd_sym_count
)));
4726 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4729 /* Read the symbols from the BFD abfd, and fills in the vector
4730 location with pointers to the symbols and a trailing NULL.
4732 Return number of symbols read. */
4735 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4739 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4741 if (PRIV (csymbols
) == NULL
)
4743 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4744 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4746 /* Traverse table and fill symbols vector. */
4747 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4749 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4752 sym
= bfd_make_empty_symbol (abfd
);
4753 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4755 bfd_release (abfd
, PRIV (csymbols
));
4756 PRIV (csymbols
) = NULL
;
4760 PRIV (csymbols
)[i
] = sym
;
4764 if (symbols
!= NULL
)
4766 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4767 symbols
[i
] = PRIV (csymbols
)[i
];
4771 return PRIV (gsd_sym_count
);
4774 /* Read and convert relocations from ETIR. We do it once for all sections. */
4777 alpha_vms_slurp_relocs (bfd
*abfd
)
4781 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4783 /* We slurp relocs only once, for all sections. */
4784 if (PRIV (reloc_done
))
4786 PRIV (reloc_done
) = TRUE
;
4788 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4791 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4796 unsigned char *begin
;
4799 bfd_reloc_code_real_type reloc_code
;
4805 bfd_vma cur_address
;
4807 unsigned char *cur_sym
= NULL
;
4809 bfd_vma cur_addend
= 0;
4811 /* Skip non-ETIR records. */
4812 type
= _bfd_vms_get_object_record (abfd
);
4813 if (type
== EOBJ__C_EEOM
)
4815 if (type
!= EOBJ__C_ETIR
)
4818 begin
= PRIV (recrd
.rec
) + 4;
4819 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4821 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4825 cmd
= bfd_getl16 (ptr
);
4826 length
= bfd_getl16 (ptr
+ 2);
4828 cur_address
= vaddr
;
4830 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4831 _bfd_vms_etir_name (cmd
)));
4835 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4836 /* ALPHA_R_REFQUAD und_section, step 1 */
4841 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4842 cur_psidx
= bfd_getl32 (ptr
+ 4);
4843 cur_addend
= bfd_getl64 (ptr
+ 8);
4847 case ETIR__C_CTL_SETRB
:
4848 if (prev_cmd
!= ETIR__C_STA_PQ
)
4850 (*_bfd_error_handler
)
4851 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
4852 _bfd_vms_etir_name (cmd
));
4855 cur_psect
= cur_psidx
;
4861 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
4862 /* ALPHA_R_REFLONG und_section, step 2 */
4865 if (prev_cmd
!= ETIR__C_STA_GBL
)
4867 (*_bfd_error_handler
)
4868 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4869 _bfd_vms_etir_name (ETIR__C_STA_LW
));
4873 cur_addend
= bfd_getl32 (ptr
+ 4);
4877 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
4878 /* ALPHA_R_REFQUAD und_section, step 2 */
4879 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
4881 (*_bfd_error_handler
)
4882 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4883 _bfd_vms_etir_name (ETIR__C_STA_QW
));
4886 cur_addend
= bfd_getl64 (ptr
+ 4);
4890 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
4891 /* ALPHA_R_REFLONG abs_section, step 2 */
4892 /* ALPHA_R_REFLONG others, step 2 */
4893 if (prev_cmd
!= ETIR__C_OPR_ADD
4894 && prev_cmd
!= ETIR__C_STA_LW
4895 && prev_cmd
!= ETIR__C_STA_PQ
)
4897 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4898 _bfd_vms_etir_name (prev_cmd
),
4899 _bfd_vms_etir_name (ETIR__C_STO_LW
));
4902 reloc_code
= BFD_RELOC_32
;
4905 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
4906 /* ALPHA_R_REFQUAD abs_section, step 2 */
4907 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
4909 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4910 _bfd_vms_etir_name (prev_cmd
),
4911 _bfd_vms_etir_name (ETIR__C_STO_QW
));
4914 reloc_code
= BFD_RELOC_64
;
4917 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
4918 if (prev_cmd
!= ETIR__C_STA_PQ
)
4920 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4921 _bfd_vms_etir_name (prev_cmd
),
4922 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
4925 reloc_code
= BFD_RELOC_64
;
4928 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
4929 /* ALPHA_R_REFQUAD und_section, step 3 */
4930 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
4932 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4933 _bfd_vms_etir_name (prev_cmd
),
4934 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
4937 prev_cmd
= ETIR__C_OPR_ADD
;
4940 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
4941 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
4945 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
4946 reloc_code
= BFD_RELOC_64
;
4950 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
4951 reloc_code
= BFD_RELOC_32
;
4955 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
4956 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
4960 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
4961 reloc_code
= BFD_RELOC_ALPHA_NOP
;
4964 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
4965 reloc_code
= BFD_RELOC_ALPHA_BSR
;
4968 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
4969 reloc_code
= BFD_RELOC_ALPHA_LDA
;
4972 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
4973 reloc_code
= BFD_RELOC_ALPHA_BOH
;
4977 cur_sym
= ptr
+ 4 + 32;
4978 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
4979 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
4982 case ETIR__C_STO_IMM
:
4983 vaddr
+= bfd_getl32 (ptr
+ 4);
4987 (*_bfd_error_handler
) (_("Unknown reloc %s"),
4988 _bfd_vms_etir_name (cmd
));
4994 struct vms_section_data_struct
*vms_sec
;
4997 /* Get section to which the relocation applies. */
4998 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5000 (*_bfd_error_handler
) (_("Invalid section index in ETIR"));
5004 sec
= PRIV (sections
)[cur_psect
];
5005 if (sec
== bfd_abs_section_ptr
)
5007 (*_bfd_error_handler
) (_("Relocation for non-REL psect"));
5011 vms_sec
= vms_section_data (sec
);
5013 /* Allocate a reloc entry. */
5014 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5016 if (vms_sec
->reloc_max
== 0)
5018 vms_sec
->reloc_max
= 64;
5019 sec
->relocation
= bfd_zmalloc
5020 (vms_sec
->reloc_max
* sizeof (arelent
));
5024 vms_sec
->reloc_max
*= 2;
5025 sec
->relocation
= bfd_realloc
5026 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5029 reloc
= &sec
->relocation
[sec
->reloc_count
];
5032 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5034 if (cur_sym
!= NULL
)
5037 unsigned int symlen
= *cur_sym
;
5040 /* Linear search. */
5045 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5046 if (PRIV (syms
)[j
]->namelen
== symlen
5047 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5049 sym
= &PRIV (csymbols
)[j
];
5054 (*_bfd_error_handler
) (_("Unknown symbol in command %s"),
5055 _bfd_vms_etir_name (cmd
));
5056 reloc
->sym_ptr_ptr
= NULL
;
5059 reloc
->sym_ptr_ptr
= sym
;
5061 else if (cur_psidx
>= 0)
5062 reloc
->sym_ptr_ptr
=
5063 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5065 reloc
->sym_ptr_ptr
= NULL
;
5067 reloc
->address
= cur_address
;
5068 reloc
->addend
= cur_addend
;
5070 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5079 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5084 /* Return the number of bytes required to store the relocation
5085 information associated with the given section. */
5088 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5090 alpha_vms_slurp_relocs (abfd
);
5092 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5095 /* Convert relocations from VMS (external) form into BFD internal
5096 form. Return the number of relocations. */
5099 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5100 asymbol
**symbols ATTRIBUTE_UNUSED
)
5105 if (!alpha_vms_slurp_relocs (abfd
))
5108 count
= section
->reloc_count
;
5109 tblptr
= section
->relocation
;
5112 *relptr
++ = tblptr
++;
5114 *relptr
= (arelent
*) NULL
;
5115 return section
->reloc_count
;
5118 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5120 /* How to process the various reloc types. */
5122 static bfd_reloc_status_type
5123 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5124 arelent
*reloc ATTRIBUTE_UNUSED
,
5125 asymbol
*sym ATTRIBUTE_UNUSED
,
5126 void * data ATTRIBUTE_UNUSED
,
5127 asection
*sec ATTRIBUTE_UNUSED
,
5128 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5129 char **error_message ATTRIBUTE_UNUSED
)
5132 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5133 vms_debug (2, "In section %s, symbol %s\n",
5134 sec
->name
, sym
->name
);
5135 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5136 reloc
->sym_ptr_ptr
[0]->name
,
5137 (unsigned long)reloc
->address
,
5138 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5139 vms_debug (2, "data at %p\n", data
);
5140 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5143 return bfd_reloc_ok
;
5146 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5147 from smaller values. Start with zero, widen, *then* decrement. */
5148 #define MINUS_ONE (((bfd_vma)0) - 1)
5150 static reloc_howto_type alpha_howto_table
[] =
5152 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5153 0, /* Rightshift. */
5154 0, /* Size (0 = byte, 1 = short, 2 = long). */
5156 TRUE
, /* PC relative. */
5158 complain_overflow_dont
,/* Complain_on_overflow. */
5159 reloc_nil
, /* Special_function. */
5160 "IGNORE", /* Name. */
5161 TRUE
, /* Partial_inplace. */
5162 0, /* Source mask */
5164 TRUE
), /* PC rel offset. */
5166 /* A 64 bit reference to a symbol. */
5167 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5168 0, /* Rightshift. */
5169 4, /* Size (0 = byte, 1 = short, 2 = long). */
5171 FALSE
, /* PC relative. */
5173 complain_overflow_bitfield
, /* Complain_on_overflow. */
5174 reloc_nil
, /* Special_function. */
5175 "REFQUAD", /* Name. */
5176 TRUE
, /* Partial_inplace. */
5177 MINUS_ONE
, /* Source mask. */
5178 MINUS_ONE
, /* Dest mask. */
5179 FALSE
), /* PC rel offset. */
5181 /* A 21 bit branch. The native assembler generates these for
5182 branches within the text segment, and also fills in the PC
5183 relative offset in the instruction. */
5184 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5185 2, /* Rightshift. */
5186 2, /* Size (0 = byte, 1 = short, 2 = long). */
5188 TRUE
, /* PC relative. */
5190 complain_overflow_signed
, /* Complain_on_overflow. */
5191 reloc_nil
, /* Special_function. */
5192 "BRADDR", /* Name. */
5193 TRUE
, /* Partial_inplace. */
5194 0x1fffff, /* Source mask. */
5195 0x1fffff, /* Dest mask. */
5196 FALSE
), /* PC rel offset. */
5198 /* A hint for a jump to a register. */
5199 HOWTO (ALPHA_R_HINT
, /* Type. */
5200 2, /* Rightshift. */
5201 1, /* Size (0 = byte, 1 = short, 2 = long). */
5203 TRUE
, /* PC relative. */
5205 complain_overflow_dont
,/* Complain_on_overflow. */
5206 reloc_nil
, /* Special_function. */
5208 TRUE
, /* Partial_inplace. */
5209 0x3fff, /* Source mask. */
5210 0x3fff, /* Dest mask. */
5211 FALSE
), /* PC rel offset. */
5213 /* 16 bit PC relative offset. */
5214 HOWTO (ALPHA_R_SREL16
, /* Type. */
5215 0, /* Rightshift. */
5216 1, /* Size (0 = byte, 1 = short, 2 = long). */
5218 TRUE
, /* PC relative. */
5220 complain_overflow_signed
, /* Complain_on_overflow. */
5221 reloc_nil
, /* Special_function. */
5222 "SREL16", /* Name. */
5223 TRUE
, /* Partial_inplace. */
5224 0xffff, /* Source mask. */
5225 0xffff, /* Dest mask. */
5226 FALSE
), /* PC rel offset. */
5228 /* 32 bit PC relative offset. */
5229 HOWTO (ALPHA_R_SREL32
, /* Type. */
5230 0, /* Rightshift. */
5231 2, /* Size (0 = byte, 1 = short, 2 = long). */
5233 TRUE
, /* PC relative. */
5235 complain_overflow_signed
, /* Complain_on_overflow. */
5236 reloc_nil
, /* Special_function. */
5237 "SREL32", /* Name. */
5238 TRUE
, /* Partial_inplace. */
5239 0xffffffff, /* Source mask. */
5240 0xffffffff, /* Dest mask. */
5241 FALSE
), /* PC rel offset. */
5243 /* A 64 bit PC relative offset. */
5244 HOWTO (ALPHA_R_SREL64
, /* Type. */
5245 0, /* Rightshift. */
5246 4, /* Size (0 = byte, 1 = short, 2 = long). */
5248 TRUE
, /* PC relative. */
5250 complain_overflow_signed
, /* Complain_on_overflow. */
5251 reloc_nil
, /* Special_function. */
5252 "SREL64", /* Name. */
5253 TRUE
, /* Partial_inplace. */
5254 MINUS_ONE
, /* Source mask. */
5255 MINUS_ONE
, /* Dest mask. */
5256 FALSE
), /* PC rel offset. */
5258 /* Push a value on the reloc evaluation stack. */
5259 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5260 0, /* Rightshift. */
5261 0, /* Size (0 = byte, 1 = short, 2 = long). */
5263 FALSE
, /* PC relative. */
5265 complain_overflow_dont
,/* Complain_on_overflow. */
5266 reloc_nil
, /* Special_function. */
5267 "OP_PUSH", /* Name. */
5268 FALSE
, /* Partial_inplace. */
5269 0, /* Source mask. */
5271 FALSE
), /* PC rel offset. */
5273 /* Store the value from the stack at the given address. Store it in
5274 a bitfield of size r_size starting at bit position r_offset. */
5275 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5276 0, /* Rightshift. */
5277 4, /* Size (0 = byte, 1 = short, 2 = long). */
5279 FALSE
, /* PC relative. */
5281 complain_overflow_dont
,/* Complain_on_overflow. */
5282 reloc_nil
, /* Special_function. */
5283 "OP_STORE", /* Name. */
5284 FALSE
, /* Partial_inplace. */
5285 0, /* Source mask. */
5286 MINUS_ONE
, /* Dest mask. */
5287 FALSE
), /* PC rel offset. */
5289 /* Subtract the reloc address from the value on the top of the
5290 relocation stack. */
5291 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5292 0, /* Rightshift. */
5293 0, /* Size (0 = byte, 1 = short, 2 = long). */
5295 FALSE
, /* PC relative. */
5297 complain_overflow_dont
,/* Complain_on_overflow. */
5298 reloc_nil
, /* Special_function. */
5299 "OP_PSUB", /* Name. */
5300 FALSE
, /* Partial_inplace. */
5301 0, /* Source mask. */
5303 FALSE
), /* PC rel offset. */
5305 /* Shift the value on the top of the relocation stack right by the
5307 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5308 0, /* Rightshift. */
5309 0, /* Size (0 = byte, 1 = short, 2 = long). */
5311 FALSE
, /* PC relative. */
5313 complain_overflow_dont
,/* Complain_on_overflow. */
5314 reloc_nil
, /* Special_function. */
5315 "OP_PRSHIFT", /* Name. */
5316 FALSE
, /* Partial_inplace. */
5317 0, /* Source mask. */
5319 FALSE
), /* PC rel offset. */
5321 /* Hack. Linkage is done by linker. */
5322 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5323 0, /* Rightshift. */
5324 8, /* Size (0 = byte, 1 = short, 2 = long). */
5326 FALSE
, /* PC relative. */
5328 complain_overflow_dont
,/* Complain_on_overflow. */
5329 reloc_nil
, /* Special_function. */
5330 "LINKAGE", /* Name. */
5331 FALSE
, /* Partial_inplace. */
5332 0, /* Source mask. */
5334 FALSE
), /* PC rel offset. */
5336 /* A 32 bit reference to a symbol. */
5337 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5338 0, /* Rightshift. */
5339 2, /* Size (0 = byte, 1 = short, 2 = long). */
5341 FALSE
, /* PC relative. */
5343 complain_overflow_bitfield
, /* Complain_on_overflow. */
5344 reloc_nil
, /* Special_function. */
5345 "REFLONG", /* Name. */
5346 TRUE
, /* Partial_inplace. */
5347 0xffffffff, /* Source mask. */
5348 0xffffffff, /* Dest mask. */
5349 FALSE
), /* PC rel offset. */
5351 /* A 64 bit reference to a procedure, written as 32 bit value. */
5352 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5353 0, /* Rightshift. */
5354 4, /* Size (0 = byte, 1 = short, 2 = long). */
5356 FALSE
, /* PC relative. */
5358 complain_overflow_signed
,/* Complain_on_overflow. */
5359 reloc_nil
, /* Special_function. */
5360 "CODEADDR", /* Name. */
5361 FALSE
, /* Partial_inplace. */
5362 0xffffffff, /* Source mask. */
5363 0xffffffff, /* Dest mask. */
5364 FALSE
), /* PC rel offset. */
5366 HOWTO (ALPHA_R_NOP
, /* Type. */
5367 0, /* Rightshift. */
5368 3, /* Size (0 = byte, 1 = short, 2 = long). */
5370 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5371 because the calculations for the 3 relocations are the same.
5372 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5373 TRUE
, /* PC relative. */
5375 complain_overflow_dont
,/* Complain_on_overflow. */
5376 reloc_nil
, /* Special_function. */
5378 FALSE
, /* Partial_inplace. */
5379 0xffffffff, /* Source mask. */
5380 0xffffffff, /* Dest mask. */
5381 FALSE
), /* PC rel offset. */
5383 HOWTO (ALPHA_R_BSR
, /* Type. */
5384 0, /* Rightshift. */
5385 3, /* Size (0 = byte, 1 = short, 2 = long). */
5387 TRUE
, /* PC relative. */
5389 complain_overflow_dont
,/* Complain_on_overflow. */
5390 reloc_nil
, /* Special_function. */
5392 FALSE
, /* Partial_inplace. */
5393 0xffffffff, /* Source mask. */
5394 0xffffffff, /* Dest mask. */
5395 FALSE
), /* PC rel offset. */
5397 HOWTO (ALPHA_R_LDA
, /* Type. */
5398 0, /* Rightshift. */
5399 3, /* Size (0 = byte, 1 = short, 2 = long). */
5401 FALSE
, /* PC relative. */
5403 complain_overflow_dont
,/* Complain_on_overflow. */
5404 reloc_nil
, /* Special_function. */
5406 FALSE
, /* Partial_inplace. */
5407 0xffffffff, /* Source mask. */
5408 0xffffffff, /* Dest mask. */
5409 FALSE
), /* PC rel offset. */
5411 HOWTO (ALPHA_R_BOH
, /* Type. */
5412 0, /* Rightshift. */
5413 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5415 TRUE
, /* PC relative. */
5417 complain_overflow_dont
,/* Complain_on_overflow. */
5418 reloc_nil
, /* Special_function. */
5420 FALSE
, /* Partial_inplace. */
5421 0xffffffff, /* Source mask. */
5422 0xffffffff, /* Dest mask. */
5423 FALSE
), /* PC rel offset. */
5426 /* Return a pointer to a howto structure which, when invoked, will perform
5427 the relocation code on data from the architecture noted. */
5429 static const struct reloc_howto_struct
*
5430 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5431 bfd_reloc_code_real_type code
)
5435 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5439 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5440 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5441 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5442 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5443 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5444 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5445 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5446 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5447 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5448 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5449 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5450 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5451 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5452 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5453 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5455 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
5458 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5459 return & alpha_howto_table
[alpha_type
];
5462 static reloc_howto_type
*
5463 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5469 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5471 if (alpha_howto_table
[i
].name
!= NULL
5472 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5473 return &alpha_howto_table
[i
];
5479 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5480 long symcount ATTRIBUTE_UNUSED
,
5481 asymbol
**usyms ATTRIBUTE_UNUSED
,
5482 long dynsymcount ATTRIBUTE_UNUSED
,
5483 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5490 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5495 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5497 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5508 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5515 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5517 value
= e
->code_value
;
5518 sec
= e
->code_section
;
5529 sname
= bfd_alloc (abfd
, l
+ 5);
5532 memcpy (sname
, name
, l
);
5533 memcpy (sname
+ l
, "..en", 5);
5540 sym
->udata
.p
= NULL
;
5549 vms_time_to_str (unsigned char *buf
)
5551 time_t t
= vms_rawtime_to_time_t (buf
);
5552 char *res
= ctime (&t
);
5555 res
= "*invalid time*";
5562 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5564 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5565 unsigned int subtype
;
5567 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5569 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5575 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5578 fprintf (file
, _("Module header\n"));
5579 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5580 fprintf (file
, _(" max record size: %u\n"),
5581 (unsigned)bfd_getl32 (mhd
->recsiz
));
5582 name
= (char *)(mhd
+ 1);
5583 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5584 name
+= name
[0] + 1;
5585 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5586 name
+= name
[0] + 1;
5587 fprintf (file
, _(" compile date : %.17s\n"), name
);
5592 fprintf (file
, _("Language Processor Name\n"));
5593 fprintf (file
, _(" language name: %.*s\n"),
5594 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5595 (char *)rec
+ sizeof (struct vms_emh_common
));
5600 fprintf (file
, _("Source Files Header\n"));
5601 fprintf (file
, _(" file: %.*s\n"),
5602 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5603 (char *)rec
+ sizeof (struct vms_emh_common
));
5608 fprintf (file
, _("Title Text Header\n"));
5609 fprintf (file
, _(" title: %.*s\n"),
5610 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5611 (char *)rec
+ sizeof (struct vms_emh_common
));
5616 fprintf (file
, _("Copyright Header\n"));
5617 fprintf (file
, _(" copyright: %.*s\n"),
5618 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5619 (char *)rec
+ sizeof (struct vms_emh_common
));
5623 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5629 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5631 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5633 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5634 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5635 (unsigned)bfd_getl32 (eeom
->total_lps
));
5636 fprintf (file
, _(" completion code: %u\n"),
5637 (unsigned)bfd_getl16 (eeom
->comcod
));
5640 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5641 fprintf (file
, _(" transfer addr psect: %u\n"),
5642 (unsigned)bfd_getl32 (eeom
->psindx
));
5643 fprintf (file
, _(" transfer address : 0x%08x\n"),
5644 (unsigned)bfd_getl32 (eeom
->tfradr
));
5649 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5651 if (flags
& EGSY__V_WEAK
)
5652 fputs (_(" WEAK"), file
);
5653 if (flags
& EGSY__V_DEF
)
5654 fputs (_(" DEF"), file
);
5655 if (flags
& EGSY__V_UNI
)
5656 fputs (_(" UNI"), file
);
5657 if (flags
& EGSY__V_REL
)
5658 fputs (_(" REL"), file
);
5659 if (flags
& EGSY__V_COMM
)
5660 fputs (_(" COMM"), file
);
5661 if (flags
& EGSY__V_VECEP
)
5662 fputs (_(" VECEP"), file
);
5663 if (flags
& EGSY__V_NORM
)
5664 fputs (_(" NORM"), file
);
5665 if (flags
& EGSY__V_QUAD_VAL
)
5666 fputs (_(" QVAL"), file
);
5670 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5672 if (flags
& EGPS__V_PIC
)
5673 fputs (_(" PIC"), file
);
5674 if (flags
& EGPS__V_LIB
)
5675 fputs (_(" LIB"), file
);
5676 if (flags
& EGPS__V_OVR
)
5677 fputs (_(" OVR"), file
);
5678 if (flags
& EGPS__V_REL
)
5679 fputs (_(" REL"), file
);
5680 if (flags
& EGPS__V_GBL
)
5681 fputs (_(" GBL"), file
);
5682 if (flags
& EGPS__V_SHR
)
5683 fputs (_(" SHR"), file
);
5684 if (flags
& EGPS__V_EXE
)
5685 fputs (_(" EXE"), file
);
5686 if (flags
& EGPS__V_RD
)
5687 fputs (_(" RD"), file
);
5688 if (flags
& EGPS__V_WRT
)
5689 fputs (_(" WRT"), file
);
5690 if (flags
& EGPS__V_VEC
)
5691 fputs (_(" VEC"), file
);
5692 if (flags
& EGPS__V_NOMOD
)
5693 fputs (_(" NOMOD"), file
);
5694 if (flags
& EGPS__V_COM
)
5695 fputs (_(" COM"), file
);
5696 if (flags
& EGPS__V_ALLOC_64BIT
)
5697 fputs (_(" 64B"), file
);
5701 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5703 unsigned int off
= sizeof (struct vms_egsd
);
5706 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5709 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5711 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5715 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5716 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5718 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5726 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5727 unsigned int flags
= bfd_getl16 (egps
->flags
);
5730 fprintf (file
, _("PSC - Program section definition\n"));
5731 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5732 fprintf (file
, _(" flags : 0x%04x"), flags
);
5733 evax_bfd_print_egsd_flags (file
, flags
);
5735 l
= bfd_getl32 (egps
->alloc
);
5736 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5737 fprintf (file
, _(" name : %.*s\n"),
5738 egps
->namlng
, egps
->name
);
5743 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5744 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5747 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5748 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5749 fprintf (file
, _(" flags : 0x%04x"), flags
);
5750 evax_bfd_print_egsd_flags (file
, flags
);
5752 l
= bfd_getl32 (esgps
->alloc
);
5753 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5754 fprintf (file
, _(" image offset : 0x%08x\n"),
5755 (unsigned int)bfd_getl32 (esgps
->base
));
5756 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5757 (unsigned int)bfd_getl32 (esgps
->value
));
5758 fprintf (file
, _(" name : %.*s\n"),
5759 esgps
->namlng
, esgps
->name
);
5764 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5765 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5767 if (flags
& EGSY__V_DEF
)
5769 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5771 fprintf (file
, _("SYM - Global symbol definition\n"));
5772 fprintf (file
, _(" flags: 0x%04x"), flags
);
5773 exav_bfd_print_egsy_flags (flags
, file
);
5775 fprintf (file
, _(" psect offset: 0x%08x\n"),
5776 (unsigned)bfd_getl32 (esdf
->value
));
5777 if (flags
& EGSY__V_NORM
)
5779 fprintf (file
, _(" code address: 0x%08x\n"),
5780 (unsigned)bfd_getl32 (esdf
->code_address
));
5781 fprintf (file
, _(" psect index for entry point : %u\n"),
5782 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5784 fprintf (file
, _(" psect index : %u\n"),
5785 (unsigned)bfd_getl32 (esdf
->psindx
));
5786 fprintf (file
, _(" name : %.*s\n"),
5787 esdf
->namlng
, esdf
->name
);
5791 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5793 fprintf (file
, _("SYM - Global symbol reference\n"));
5794 fprintf (file
, _(" name : %.*s\n"),
5795 esrf
->namlng
, esrf
->name
);
5801 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
5802 unsigned int flags
= bfd_getl32 (eidc
->flags
);
5805 fprintf (file
, _("IDC - Ident Consistency check\n"));
5806 fprintf (file
, _(" flags : 0x%08x"), flags
);
5807 if (flags
& EIDC__V_BINIDENT
)
5808 fputs (" BINDENT", file
);
5810 fprintf (file
, _(" id match : %x\n"),
5811 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
5812 fprintf (file
, _(" error severity: %x\n"),
5813 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
5815 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
5817 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
5819 if (flags
& EIDC__V_BINIDENT
)
5820 fprintf (file
, _(" binary ident : 0x%08x\n"),
5821 (unsigned)bfd_getl32 (p
+ 1));
5823 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
5828 struct vms_egst
*egst
= (struct vms_egst
*)e
;
5829 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
5831 fprintf (file
, _("SYMG - Universal symbol definition\n"));
5832 fprintf (file
, _(" flags: 0x%04x"), flags
);
5833 exav_bfd_print_egsy_flags (flags
, file
);
5835 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
5836 (unsigned)bfd_getl32 (egst
->value
));
5837 fprintf (file
, _(" entry point: 0x%08x\n"),
5838 (unsigned)bfd_getl32 (egst
->lp_1
));
5839 fprintf (file
, _(" proc descr : 0x%08x\n"),
5840 (unsigned)bfd_getl32 (egst
->lp_2
));
5841 fprintf (file
, _(" psect index: %u\n"),
5842 (unsigned)bfd_getl32 (egst
->psindx
));
5843 fprintf (file
, _(" name : %.*s\n"),
5844 egst
->namlng
, egst
->name
);
5849 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
5850 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
5852 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
5853 fprintf (file
, _(" flags: 0x%04x"), flags
);
5854 exav_bfd_print_egsy_flags (flags
, file
);
5856 fprintf (file
, _(" vector : 0x%08x\n"),
5857 (unsigned)bfd_getl32 (esdfv
->vector
));
5858 fprintf (file
, _(" psect offset: %u\n"),
5859 (unsigned)bfd_getl32 (esdfv
->value
));
5860 fprintf (file
, _(" psect index : %u\n"),
5861 (unsigned)bfd_getl32 (esdfv
->psindx
));
5862 fprintf (file
, _(" name : %.*s\n"),
5863 esdfv
->namlng
, esdfv
->name
);
5868 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
5869 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
5871 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
5872 fprintf (file
, _(" flags: 0x%04x"), flags
);
5873 exav_bfd_print_egsy_flags (flags
, file
);
5875 fprintf (file
, _(" version mask: 0x%08x\n"),
5876 (unsigned)bfd_getl32 (esdfm
->version_mask
));
5877 fprintf (file
, _(" psect offset: %u\n"),
5878 (unsigned)bfd_getl32 (esdfm
->value
));
5879 fprintf (file
, _(" psect index : %u\n"),
5880 (unsigned)bfd_getl32 (esdfm
->psindx
));
5881 fprintf (file
, _(" name : %.*s\n"),
5882 esdfm
->namlng
, esdfm
->name
);
5886 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
5894 evax_bfd_print_hex (FILE *file
, const char *pfx
,
5895 const unsigned char *buf
, unsigned int len
)
5901 for (i
= 0; i
< len
; i
++)
5905 fprintf (file
, " %02x", buf
[i
]);
5918 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
5920 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
5921 (unsigned)bfd_getl32 (buf
),
5922 (unsigned)bfd_getl32 (buf
+ 16));
5923 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
5924 (unsigned)bfd_getl32 (buf
+ 4),
5925 (unsigned)bfd_getl32 (buf
+ 12),
5926 (unsigned)bfd_getl32 (buf
+ 8));
5927 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
5928 (unsigned)bfd_getl32 (buf
+ 20),
5929 (unsigned)bfd_getl32 (buf
+ 28),
5930 (unsigned)bfd_getl32 (buf
+ 24));
5932 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
5933 (unsigned)bfd_getl32 (buf
+ 32),
5934 (unsigned)bfd_getl32 (buf
+ 40),
5935 (unsigned)bfd_getl32 (buf
+ 36));
5937 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
5941 evax_bfd_print_etir (FILE *file
, const char *name
,
5942 unsigned char *rec
, unsigned int rec_len
)
5944 unsigned int off
= sizeof (struct vms_egsd
);
5945 unsigned int sec_len
= 0;
5947 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
5948 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
5949 (unsigned)sizeof (struct vms_eobjrec
));
5951 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
5953 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
5958 type
= bfd_getl16 (etir
->rectyp
);
5959 size
= bfd_getl16 (etir
->size
);
5960 buf
= rec
+ off
+ sizeof (struct vms_etir
);
5962 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
5965 case ETIR__C_STA_GBL
:
5966 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
5969 case ETIR__C_STA_LW
:
5970 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
5971 (unsigned)bfd_getl32 (buf
));
5973 case ETIR__C_STA_QW
:
5974 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
5975 (unsigned)bfd_getl32 (buf
+ 4),
5976 (unsigned)bfd_getl32 (buf
+ 0));
5978 case ETIR__C_STA_PQ
:
5979 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
5980 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
5981 (unsigned)bfd_getl32 (buf
+ 0),
5982 (unsigned)bfd_getl32 (buf
+ 8),
5983 (unsigned)bfd_getl32 (buf
+ 4));
5985 case ETIR__C_STA_LI
:
5986 fprintf (file
, _("STA_LI (stack literal)\n"));
5988 case ETIR__C_STA_MOD
:
5989 fprintf (file
, _("STA_MOD (stack module)\n"));
5991 case ETIR__C_STA_CKARG
:
5992 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
5996 fprintf (file
, _("STO_B (store byte)\n"));
5999 fprintf (file
, _("STO_W (store word)\n"));
6001 case ETIR__C_STO_LW
:
6002 fprintf (file
, _("STO_LW (store longword)\n"));
6004 case ETIR__C_STO_QW
:
6005 fprintf (file
, _("STO_QW (store quadword)\n"));
6007 case ETIR__C_STO_IMMR
:
6009 unsigned int len
= bfd_getl32 (buf
);
6011 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6013 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6017 case ETIR__C_STO_GBL
:
6018 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6021 case ETIR__C_STO_CA
:
6022 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6025 case ETIR__C_STO_RB
:
6026 fprintf (file
, _("STO_RB (store relative branch)\n"));
6028 case ETIR__C_STO_AB
:
6029 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6031 case ETIR__C_STO_OFF
:
6032 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6034 case ETIR__C_STO_IMM
:
6036 unsigned int len
= bfd_getl32 (buf
);
6038 _("STO_IMM (store immediate) %u bytes\n"),
6040 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6044 case ETIR__C_STO_GBL_LW
:
6045 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6048 case ETIR__C_STO_LP_PSB
:
6049 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6051 case ETIR__C_STO_HINT_GBL
:
6052 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6054 case ETIR__C_STO_HINT_PS
:
6055 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6058 case ETIR__C_OPR_NOP
:
6059 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6061 case ETIR__C_OPR_ADD
:
6062 fprintf (file
, _("OPR_ADD (add)\n"));
6064 case ETIR__C_OPR_SUB
:
6065 fprintf (file
, _("OPR_SUB (substract)\n"));
6067 case ETIR__C_OPR_MUL
:
6068 fprintf (file
, _("OPR_MUL (multiply)\n"));
6070 case ETIR__C_OPR_DIV
:
6071 fprintf (file
, _("OPR_DIV (divide)\n"));
6073 case ETIR__C_OPR_AND
:
6074 fprintf (file
, _("OPR_AND (logical and)\n"));
6076 case ETIR__C_OPR_IOR
:
6077 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6079 case ETIR__C_OPR_EOR
:
6080 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6082 case ETIR__C_OPR_NEG
:
6083 fprintf (file
, _("OPR_NEG (negate)\n"));
6085 case ETIR__C_OPR_COM
:
6086 fprintf (file
, _("OPR_COM (complement)\n"));
6088 case ETIR__C_OPR_INSV
:
6089 fprintf (file
, _("OPR_INSV (insert field)\n"));
6091 case ETIR__C_OPR_ASH
:
6092 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6094 case ETIR__C_OPR_USH
:
6095 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6097 case ETIR__C_OPR_ROT
:
6098 fprintf (file
, _("OPR_ROT (rotate)\n"));
6100 case ETIR__C_OPR_SEL
:
6101 fprintf (file
, _("OPR_SEL (select)\n"));
6103 case ETIR__C_OPR_REDEF
:
6104 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6106 case ETIR__C_OPR_DFLIT
:
6107 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6110 case ETIR__C_STC_LP
:
6111 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6113 case ETIR__C_STC_LP_PSB
:
6115 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6116 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6117 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6118 buf
+= 4 + 1 + buf
[4];
6119 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6121 case ETIR__C_STC_GBL
:
6122 fprintf (file
, _("STC_GBL (store cond global)\n"));
6123 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6124 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6126 case ETIR__C_STC_GCA
:
6127 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6128 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6129 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6131 case ETIR__C_STC_PS
:
6132 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6134 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6135 (unsigned)bfd_getl32 (buf
),
6136 (unsigned)bfd_getl32 (buf
+ 4),
6137 (unsigned)bfd_getl32 (buf
+ 12),
6138 (unsigned)bfd_getl32 (buf
+ 8));
6140 case ETIR__C_STC_NOP_GBL
:
6141 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6142 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6144 case ETIR__C_STC_NOP_PS
:
6145 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6146 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6148 case ETIR__C_STC_BSR_GBL
:
6149 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6150 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6152 case ETIR__C_STC_BSR_PS
:
6153 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6154 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6156 case ETIR__C_STC_LDA_GBL
:
6157 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6158 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6160 case ETIR__C_STC_LDA_PS
:
6161 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6162 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6164 case ETIR__C_STC_BOH_GBL
:
6165 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6166 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6168 case ETIR__C_STC_BOH_PS
:
6169 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6170 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6172 case ETIR__C_STC_NBH_GBL
:
6174 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6176 case ETIR__C_STC_NBH_PS
:
6178 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6181 case ETIR__C_CTL_SETRB
:
6182 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6185 case ETIR__C_CTL_AUGRB
:
6187 unsigned int val
= bfd_getl32 (buf
);
6188 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6191 case ETIR__C_CTL_DFLOC
:
6192 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6194 case ETIR__C_CTL_STLOC
:
6195 fprintf (file
, _("CTL_STLOC (set location)\n"));
6197 case ETIR__C_CTL_STKDL
:
6198 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6201 fprintf (file
, _("*unhandled*\n"));
6209 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6211 bfd_boolean is_first
= TRUE
;
6212 bfd_boolean has_records
= FALSE
;
6216 unsigned int rec_len
;
6217 unsigned int pad_len
;
6219 unsigned int hdr_size
;
6224 unsigned char buf
[6];
6229 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6231 fprintf (file
, _("cannot read GST record length\n"));
6234 rec_len
= bfd_getl16 (buf
+ 0);
6235 if (rec_len
== bfd_getl16 (buf
+ 4)
6236 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6238 /* The format is raw: record-size, type, record-size. */
6240 pad_len
= (rec_len
+ 1) & ~1U;
6243 else if (rec_len
== EOBJ__C_EMH
)
6245 has_records
= FALSE
;
6246 pad_len
= bfd_getl16 (buf
+ 2);
6252 fprintf (file
, _("cannot find EMH in first GST record\n"));
6255 rec
= bfd_malloc (pad_len
);
6256 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6260 unsigned int rec_len2
= 0;
6261 unsigned char hdr
[4];
6265 unsigned char buf_len
[2];
6267 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6268 != sizeof (buf_len
))
6270 fprintf (file
, _("cannot read GST record length\n"));
6273 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6276 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6278 fprintf (file
, _("cannot read GST record header\n"));
6281 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6283 pad_len
= (rec_len
+ 1) & ~1U;
6286 rec
= bfd_malloc (pad_len
);
6287 memcpy (rec
, hdr
, sizeof (hdr
));
6288 hdr_size
= sizeof (hdr
);
6289 if (has_records
&& rec_len2
!= rec_len
)
6291 fprintf (file
, _(" corrupted GST\n"));
6296 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6297 != pad_len
- hdr_size
)
6299 fprintf (file
, _("cannot read GST record\n"));
6303 type
= (unsigned)bfd_getl16 (rec
);
6308 evax_bfd_print_emh (file
, rec
, rec_len
);
6311 evax_bfd_print_egsd (file
, rec
, rec_len
);
6314 evax_bfd_print_eeom (file
, rec
, rec_len
);
6319 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6322 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6325 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6328 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6336 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6337 unsigned int stride
)
6345 count
= bfd_getl32 (rel
+ 0);
6349 base
= bfd_getl32 (rel
+ 4);
6351 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6355 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6361 val
= bfd_getl32 (rel
);
6364 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6366 for (k
= 0; k
< 32; k
++)
6371 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6386 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6393 count
= bfd_getl32 (rel
+ 0);
6396 fprintf (file
, _(" image %u (%u entries)\n"),
6397 (unsigned)bfd_getl32 (rel
+ 4), count
);
6399 for (j
= 0; j
< count
; j
++)
6401 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6402 (unsigned)bfd_getl32 (rel
+ 0),
6403 (unsigned)bfd_getl32 (rel
+ 4));
6410 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6419 count
= bfd_getl32 (rel
+ 0);
6422 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6423 (unsigned)bfd_getl32 (rel
+ 4), count
);
6425 for (j
= 0; j
< count
; j
++)
6429 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6444 evax_bfd_print_indent (int indent
, FILE *file
)
6446 for (; indent
; indent
--)
6451 evax_bfd_get_dsc_name (unsigned int v
)
6455 case DSC__K_DTYPE_Z
:
6456 return "Z (Unspecified)";
6457 case DSC__K_DTYPE_V
:
6459 case DSC__K_DTYPE_BU
:
6460 return "BU (Byte logical)";
6461 case DSC__K_DTYPE_WU
:
6462 return "WU (Word logical)";
6463 case DSC__K_DTYPE_LU
:
6464 return "LU (Longword logical)";
6465 case DSC__K_DTYPE_QU
:
6466 return "QU (Quadword logical)";
6467 case DSC__K_DTYPE_B
:
6468 return "B (Byte integer)";
6469 case DSC__K_DTYPE_W
:
6470 return "W (Word integer)";
6471 case DSC__K_DTYPE_L
:
6472 return "L (Longword integer)";
6473 case DSC__K_DTYPE_Q
:
6474 return "Q (Quadword integer)";
6475 case DSC__K_DTYPE_F
:
6476 return "F (Single-precision floating)";
6477 case DSC__K_DTYPE_D
:
6478 return "D (Double-precision floating)";
6479 case DSC__K_DTYPE_FC
:
6480 return "FC (Complex)";
6481 case DSC__K_DTYPE_DC
:
6482 return "DC (Double-precision Complex)";
6483 case DSC__K_DTYPE_T
:
6484 return "T (ASCII text string)";
6485 case DSC__K_DTYPE_NU
:
6486 return "NU (Numeric string, unsigned)";
6487 case DSC__K_DTYPE_NL
:
6488 return "NL (Numeric string, left separate sign)";
6489 case DSC__K_DTYPE_NLO
:
6490 return "NLO (Numeric string, left overpunched sign)";
6491 case DSC__K_DTYPE_NR
:
6492 return "NR (Numeric string, right separate sign)";
6493 case DSC__K_DTYPE_NRO
:
6494 return "NRO (Numeric string, right overpunched sig)";
6495 case DSC__K_DTYPE_NZ
:
6496 return "NZ (Numeric string, zoned sign)";
6497 case DSC__K_DTYPE_P
:
6498 return "P (Packed decimal string)";
6499 case DSC__K_DTYPE_ZI
:
6500 return "ZI (Sequence of instructions)";
6501 case DSC__K_DTYPE_ZEM
:
6502 return "ZEM (Procedure entry mask)";
6503 case DSC__K_DTYPE_DSC
:
6504 return "DSC (Descriptor, used for arrays of dyn strings)";
6505 case DSC__K_DTYPE_OU
:
6506 return "OU (Octaword logical)";
6507 case DSC__K_DTYPE_O
:
6508 return "O (Octaword integer)";
6509 case DSC__K_DTYPE_G
:
6510 return "G (Double precision G floating, 64 bit)";
6511 case DSC__K_DTYPE_H
:
6512 return "H (Quadruple precision floating, 128 bit)";
6513 case DSC__K_DTYPE_GC
:
6514 return "GC (Double precision complex, G floating)";
6515 case DSC__K_DTYPE_HC
:
6516 return "HC (Quadruple precision complex, H floating)";
6517 case DSC__K_DTYPE_CIT
:
6518 return "CIT (COBOL intermediate temporary)";
6519 case DSC__K_DTYPE_BPV
:
6520 return "BPV (Bound Procedure Value)";
6521 case DSC__K_DTYPE_BLV
:
6522 return "BLV (Bound Label Value)";
6523 case DSC__K_DTYPE_VU
:
6524 return "VU (Bit Unaligned)";
6525 case DSC__K_DTYPE_ADT
:
6526 return "ADT (Absolute Date-Time)";
6527 case DSC__K_DTYPE_VT
:
6528 return "VT (Varying Text)";
6529 case DSC__K_DTYPE_T2
:
6530 return "T2 (16-bit char)";
6531 case DSC__K_DTYPE_VT2
:
6532 return "VT2 (16-bit varying char)";
6534 return "?? (unknown)";
6539 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6541 unsigned char bclass
= buf
[3];
6542 unsigned char dtype
= buf
[2];
6543 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6544 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6546 evax_bfd_print_indent (indent
, file
);
6548 if (len
== 1 && pointer
== 0xffffffffUL
)
6551 fprintf (file
, _("64 bits *unhandled*\n"));
6555 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6556 bclass
, dtype
, len
, pointer
);
6559 case DSC__K_CLASS_NCA
:
6561 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6563 const unsigned char *b
;
6565 evax_bfd_print_indent (indent
, file
);
6566 fprintf (file
, _("non-contiguous array of %s\n"),
6567 evax_bfd_get_dsc_name (dsc
->dtype
));
6568 evax_bfd_print_indent (indent
+ 1, file
);
6570 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6571 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6572 evax_bfd_print_indent (indent
+ 1, file
);
6574 _("arsize: %u, a0: 0x%08x\n"),
6575 (unsigned)bfd_getl32 (dsc
->arsize
),
6576 (unsigned)bfd_getl32 (dsc
->a0
));
6577 evax_bfd_print_indent (indent
+ 1, file
);
6578 fprintf (file
, _("Strides:\n"));
6579 b
= buf
+ sizeof (*dsc
);
6580 for (i
= 0; i
< dsc
->dimct
; i
++)
6582 evax_bfd_print_indent (indent
+ 2, file
);
6583 fprintf (file
, _("[%u]: %u\n"), i
+ 1,
6584 (unsigned)bfd_getl32 (b
));
6587 evax_bfd_print_indent (indent
+ 1, file
);
6588 fprintf (file
, _("Bounds:\n"));
6589 b
= buf
+ sizeof (*dsc
);
6590 for (i
= 0; i
< dsc
->dimct
; i
++)
6592 evax_bfd_print_indent (indent
+ 2, file
);
6593 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6594 (unsigned)bfd_getl32 (b
+ 0),
6595 (unsigned)bfd_getl32 (b
+ 4));
6600 case DSC__K_CLASS_UBS
:
6602 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6604 evax_bfd_print_indent (indent
, file
);
6605 fprintf (file
, _("unaligned bit-string of %s\n"),
6606 evax_bfd_get_dsc_name (ubs
->dtype
));
6607 evax_bfd_print_indent (indent
+ 1, file
);
6609 _("base: %u, pos: %u\n"),
6610 (unsigned)bfd_getl32 (ubs
->base
),
6611 (unsigned)bfd_getl32 (ubs
->pos
));
6615 fprintf (file
, _("*unhandled*\n"));
6622 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6624 unsigned int vflags
= buf
[0];
6625 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6626 unsigned int len
= 5;
6628 evax_bfd_print_indent (indent
, file
);
6629 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6634 case DST__K_VFLAGS_NOVAL
:
6635 fprintf (file
, _("(no value)\n"));
6637 case DST__K_VFLAGS_NOTACTIVE
:
6638 fprintf (file
, _("(not active)\n"));
6640 case DST__K_VFLAGS_UNALLOC
:
6641 fprintf (file
, _("(not allocated)\n"));
6643 case DST__K_VFLAGS_DSC
:
6644 fprintf (file
, _("(descriptor)\n"));
6645 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6647 case DST__K_VFLAGS_TVS
:
6648 fprintf (file
, _("(trailing value)\n"));
6650 case DST__K_VS_FOLLOWS
:
6651 fprintf (file
, _("(value spec follows)\n"));
6653 case DST__K_VFLAGS_BITOFFS
:
6654 fprintf (file
, _("(at bit offset %u)\n"), value
);
6657 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6658 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6659 vflags
& DST__K_DISP
? 1 : 0,
6660 vflags
& DST__K_INDIR
? 1 : 0);
6661 switch (vflags
& DST__K_VALKIND_MASK
)
6663 case DST__K_VALKIND_LITERAL
:
6664 fputs (_("literal"), file
);
6666 case DST__K_VALKIND_ADDR
:
6667 fputs (_("address"), file
);
6669 case DST__K_VALKIND_DESC
:
6670 fputs (_("desc"), file
);
6672 case DST__K_VALKIND_REG
:
6673 fputs (_("reg"), file
);
6676 fputs (")\n", file
);
6683 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6685 unsigned char kind
= buf
[2];
6686 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6688 evax_bfd_print_indent (indent
, file
);
6689 fprintf (file
, ("len: %2u, kind: %2u "), len
, kind
);
6693 case DST__K_TS_ATOM
:
6694 fprintf (file
, ("atomic, type=0x%02x %s\n"),
6695 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6698 fprintf (file
, ("indirect, defined at 0x%08x\n"),
6699 (unsigned)bfd_getl32 (buf
));
6701 case DST__K_TS_TPTR
:
6702 fprintf (file
, ("typed pointer\n"));
6703 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6706 fprintf (file
, ("pointer\n"));
6708 case DST__K_TS_ARRAY
:
6710 const unsigned char *vs
;
6711 unsigned int vec_len
;
6714 fprintf (file
, ("array, dim: %u, bitmap: "), buf
[0]);
6715 vec_len
= (buf
[0] + 1 + 7) / 8;
6716 for (i
= 0; i
< vec_len
; i
++)
6717 fprintf (file
, " %02x", buf
[i
+ 1]);
6719 vs
= buf
+ 1 + vec_len
;
6720 evax_bfd_print_indent (indent
, file
);
6721 fprintf (file
, ("array descriptor:\n"));
6722 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6723 for (i
= 0; i
< buf
[0] + 1U; i
++)
6724 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6726 evax_bfd_print_indent (indent
, file
);
6728 fprintf (file
, ("type spec for element:\n"));
6730 fprintf (file
, ("type spec for subscript %u:\n"), i
);
6731 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6732 vs
+= bfd_getl16 (vs
);
6737 fprintf (file
, ("*unhandled*\n"));
6742 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6744 unsigned int off
= 0;
6745 unsigned int pc
= 0;
6746 unsigned int line
= 0;
6748 fprintf (file
, _("Debug symbol table:\n"));
6750 while (dst_size
> 0)
6752 struct vms_dst_header dsth
;
6757 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6759 fprintf (file
, _("cannot read DST header\n"));
6762 len
= bfd_getl16 (dsth
.length
);
6763 type
= bfd_getl16 (dsth
.type
);
6764 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
6774 len
-= sizeof (dsth
);
6775 buf
= bfd_malloc (len
);
6776 if (bfd_bread (buf
, len
, abfd
) != len
)
6778 fprintf (file
, _("cannot read DST symbol\n"));
6783 case DSC__K_DTYPE_V
:
6784 case DSC__K_DTYPE_BU
:
6785 case DSC__K_DTYPE_WU
:
6786 case DSC__K_DTYPE_LU
:
6787 case DSC__K_DTYPE_QU
:
6788 case DSC__K_DTYPE_B
:
6789 case DSC__K_DTYPE_W
:
6790 case DSC__K_DTYPE_L
:
6791 case DSC__K_DTYPE_Q
:
6792 case DSC__K_DTYPE_F
:
6793 case DSC__K_DTYPE_D
:
6794 case DSC__K_DTYPE_FC
:
6795 case DSC__K_DTYPE_DC
:
6796 case DSC__K_DTYPE_T
:
6797 case DSC__K_DTYPE_NU
:
6798 case DSC__K_DTYPE_NL
:
6799 case DSC__K_DTYPE_NLO
:
6800 case DSC__K_DTYPE_NR
:
6801 case DSC__K_DTYPE_NRO
:
6802 case DSC__K_DTYPE_NZ
:
6803 case DSC__K_DTYPE_P
:
6804 case DSC__K_DTYPE_ZI
:
6805 case DSC__K_DTYPE_ZEM
:
6806 case DSC__K_DTYPE_DSC
:
6807 case DSC__K_DTYPE_OU
:
6808 case DSC__K_DTYPE_O
:
6809 case DSC__K_DTYPE_G
:
6810 case DSC__K_DTYPE_H
:
6811 case DSC__K_DTYPE_GC
:
6812 case DSC__K_DTYPE_HC
:
6813 case DSC__K_DTYPE_CIT
:
6814 case DSC__K_DTYPE_BPV
:
6815 case DSC__K_DTYPE_BLV
:
6816 case DSC__K_DTYPE_VU
:
6817 case DSC__K_DTYPE_ADT
:
6818 case DSC__K_DTYPE_VT
:
6819 case DSC__K_DTYPE_T2
:
6820 case DSC__K_DTYPE_VT2
:
6821 fprintf (file
, _("standard data: %s\n"),
6822 evax_bfd_get_dsc_name (type
));
6823 evax_bfd_print_valspec (buf
, 4, file
);
6824 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
6828 struct vms_dst_modbeg
*dst
= (void *)buf
;
6829 const char *name
= (const char *)buf
+ sizeof (*dst
);
6831 fprintf (file
, _("modbeg\n"));
6832 fprintf (file
, _(" flags: %d, language: %u, "
6833 "major: %u, minor: %u\n"),
6835 (unsigned)bfd_getl32 (dst
->language
),
6836 (unsigned)bfd_getl16 (dst
->major
),
6837 (unsigned)bfd_getl16 (dst
->minor
));
6838 fprintf (file
, _(" module name: %.*s\n"),
6840 name
+= name
[0] + 1;
6841 fprintf (file
, _(" compiler : %.*s\n"),
6846 fprintf (file
, _("modend\n"));
6850 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
6851 const char *name
= (const char *)buf
+ sizeof (*dst
);
6853 fputs (_("rtnbeg\n"), file
);
6854 fprintf (file
, _(" flags: %u, address: 0x%08x, "
6855 "pd-address: 0x%08x\n"),
6857 (unsigned)bfd_getl32 (dst
->address
),
6858 (unsigned)bfd_getl32 (dst
->pd_address
));
6859 fprintf (file
, _(" routine name: %.*s\n"),
6865 struct vms_dst_rtnend
*dst
= (void *)buf
;
6867 fprintf (file
, _("rtnend: size 0x%08x\n"),
6868 (unsigned)bfd_getl32 (dst
->size
));
6873 struct vms_dst_prolog
*dst
= (void *)buf
;
6875 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
6876 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
6881 struct vms_dst_epilog
*dst
= (void *)buf
;
6883 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
6884 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
6889 struct vms_dst_blkbeg
*dst
= (void *)buf
;
6890 const char *name
= (const char *)buf
+ sizeof (*dst
);
6892 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6893 (unsigned)bfd_getl32 (dst
->address
),
6899 struct vms_dst_blkend
*dst
= (void *)buf
;
6901 fprintf (file
, _("blkend: size: 0x%08x\n"),
6902 (unsigned)bfd_getl32 (dst
->size
));
6905 case DST__K_TYPSPEC
:
6907 fprintf (file
, _("typspec (len: %u)\n"), len
);
6908 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
6909 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
6914 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
6915 evax_bfd_print_valspec (buf
, 4, file
);
6920 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
6921 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
6923 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
6924 evax_bfd_print_valspec (buf
, 4, file
);
6925 fprintf (file
, (" len: %u bits\n"),
6926 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
6930 fprintf (file
, _("recend\n"));
6932 case DST__K_ENUMBEG
:
6933 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
6934 buf
[0], buf
[1], buf
+ 2);
6936 case DST__K_ENUMELT
:
6937 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
6938 evax_bfd_print_valspec (buf
, 4, file
);
6940 case DST__K_ENUMEND
:
6941 fprintf (file
, _("enumend\n"));
6945 struct vms_dst_label
*lab
= (void *)buf
;
6946 fprintf (file
, ("label, name: %.*s\n"),
6947 lab
->name
[0], lab
->name
+ 1);
6948 fprintf (file
, (" address: 0x%08x\n"),
6949 (unsigned)bfd_getl32 (lab
->value
));
6952 case DST__K_DIS_RANGE
:
6954 unsigned int cnt
= bfd_getl32 (buf
);
6955 unsigned char *rng
= buf
+ 4;
6958 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
6959 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
6960 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
6961 (unsigned)bfd_getl32 (rng
),
6962 (unsigned)bfd_getl32 (rng
+ 4));
6966 case DST__K_LINE_NUM
:
6968 unsigned char *buf_orig
= buf
;
6970 fprintf (file
, _("line num (len: %u)\n"), len
);
6975 unsigned char cmdlen
;
6985 case DST__K_DELTA_PC_W
:
6986 val
= bfd_getl16 (buf
+ 1);
6987 fprintf (file
, _("delta_pc_w %u\n"), val
);
6992 case DST__K_INCR_LINUM
:
6994 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
6998 case DST__K_INCR_LINUM_W
:
6999 val
= bfd_getl16 (buf
+ 1);
7000 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7004 case DST__K_INCR_LINUM_L
:
7005 val
= bfd_getl32 (buf
+ 1);
7006 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7010 case DST__K_SET_LINUM
:
7011 line
= bfd_getl16 (buf
+ 1);
7012 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7015 case DST__K_SET_LINUM_B
:
7017 fprintf (file
, _("set_line_num_b %u\n"), line
);
7020 case DST__K_SET_LINUM_L
:
7021 line
= bfd_getl32 (buf
+ 1);
7022 fprintf (file
, _("set_line_num_l %u\n"), line
);
7025 case DST__K_SET_ABS_PC
:
7026 pc
= bfd_getl32 (buf
+ 1);
7027 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7030 case DST__K_DELTA_PC_L
:
7031 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7032 (unsigned)bfd_getl32 (buf
+ 1));
7036 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7038 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7042 val
= bfd_getl16 (buf
+ 1);
7043 fprintf (file
, _("term_w: 0x%04x"), val
);
7045 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7051 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7052 line
++; /* FIXME: curr increment. */
7054 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7059 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7072 unsigned char *buf_orig
= buf
;
7074 fprintf (file
, _("source (len: %u)\n"), len
);
7078 signed char cmd
= buf
[0];
7079 unsigned char cmdlen
= 0;
7083 case DST__K_SRC_DECLFILE
:
7085 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7088 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7090 src
->length
, src
->flags
,
7091 (unsigned)bfd_getl16 (src
->fileid
));
7092 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7093 "ebk: 0x%08x, ffb: 0x%04x, "
7095 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7096 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7097 (unsigned)bfd_getl32 (src
->rms_ebk
),
7098 (unsigned)bfd_getl16 (src
->rms_ffb
),
7100 name
= (const char *)buf
+ 1 + sizeof (*src
);
7101 fprintf (file
, _(" filename : %.*s\n"),
7103 name
+= name
[0] + 1;
7104 fprintf (file
, _(" module name: %.*s\n"),
7106 cmdlen
= 2 + src
->length
;
7109 case DST__K_SRC_SETFILE
:
7110 fprintf (file
, _(" setfile %u\n"),
7111 (unsigned)bfd_getl16 (buf
+ 1));
7114 case DST__K_SRC_SETREC_W
:
7115 fprintf (file
, _(" setrec %u\n"),
7116 (unsigned)bfd_getl16 (buf
+ 1));
7119 case DST__K_SRC_SETREC_L
:
7120 fprintf (file
, _(" setrec %u\n"),
7121 (unsigned)bfd_getl32 (buf
+ 1));
7124 case DST__K_SRC_SETLNUM_W
:
7125 fprintf (file
, _(" setlnum %u\n"),
7126 (unsigned)bfd_getl16 (buf
+ 1));
7129 case DST__K_SRC_SETLNUM_L
:
7130 fprintf (file
, _(" setlnum %u\n"),
7131 (unsigned)bfd_getl32 (buf
+ 1));
7134 case DST__K_SRC_DEFLINES_W
:
7135 fprintf (file
, _(" deflines %u\n"),
7136 (unsigned)bfd_getl16 (buf
+ 1));
7139 case DST__K_SRC_DEFLINES_B
:
7140 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7143 case DST__K_SRC_FORMFEED
:
7144 fprintf (file
, _(" formfeed\n"));
7148 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7160 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7168 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7170 struct vms_eihd eihd
;
7173 unsigned int eiha_off
;
7174 unsigned int eihi_off
;
7175 unsigned int eihs_off
;
7176 unsigned int eisd_off
;
7177 unsigned int eihef_off
= 0;
7178 unsigned int eihnp_off
= 0;
7179 unsigned int dmt_vbn
= 0;
7180 unsigned int dmt_size
= 0;
7181 unsigned int dst_vbn
= 0;
7182 unsigned int dst_size
= 0;
7183 unsigned int gst_vbn
= 0;
7184 unsigned int gst_size
= 0;
7185 unsigned int eiaf_vbn
= 0;
7186 unsigned int eiaf_size
= 0;
7187 unsigned int eihvn_off
;
7189 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7190 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7192 fprintf (file
, _("cannot read EIHD\n"));
7195 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7196 (unsigned)bfd_getl32 (eihd
.size
),
7197 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7198 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7199 (unsigned)bfd_getl32 (eihd
.majorid
),
7200 (unsigned)bfd_getl32 (eihd
.minorid
));
7202 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7206 name
= _("executable");
7209 name
= _("linkable image");
7212 name
= _("unknown");
7215 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7217 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7220 case EIHD__C_NATIVE
:
7227 name
= _("unknown");
7230 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7232 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7233 eiha_off
= bfd_getl32 (eihd
.activoff
);
7234 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7235 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7236 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7237 "imgid: %u, patch: %u\n"),
7238 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7239 (unsigned)bfd_getl32 (eihd
.patchoff
));
7240 fprintf (file
, _(" fixup info rva: "));
7241 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7242 fprintf (file
, _(", symbol vector rva: "));
7243 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7244 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7245 fprintf (file
, _("\n"
7246 " version array off: %u\n"),
7249 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7250 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7251 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7252 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7253 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7254 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7255 fprintf (file
, _(" linker flags: %08x:"), val
);
7256 if (val
& EIHD__M_LNKDEBUG
)
7257 fprintf (file
, " LNKDEBUG");
7258 if (val
& EIHD__M_LNKNOTFR
)
7259 fprintf (file
, " LNKNOTFR");
7260 if (val
& EIHD__M_NOP0BUFS
)
7261 fprintf (file
, " NOP0BUFS");
7262 if (val
& EIHD__M_PICIMG
)
7263 fprintf (file
, " PICIMG");
7264 if (val
& EIHD__M_P0IMAGE
)
7265 fprintf (file
, " P0IMAGE");
7266 if (val
& EIHD__M_DBGDMT
)
7267 fprintf (file
, " DBGDMT");
7268 if (val
& EIHD__M_INISHR
)
7269 fprintf (file
, " INISHR");
7270 if (val
& EIHD__M_XLATED
)
7271 fprintf (file
, " XLATED");
7272 if (val
& EIHD__M_BIND_CODE_SEC
)
7273 fprintf (file
, " BIND_CODE_SEC");
7274 if (val
& EIHD__M_BIND_DATA_SEC
)
7275 fprintf (file
, " BIND_DATA_SEC");
7276 if (val
& EIHD__M_MKTHREADS
)
7277 fprintf (file
, " MKTHREADS");
7278 if (val
& EIHD__M_UPCALLS
)
7279 fprintf (file
, " UPCALLS");
7280 if (val
& EIHD__M_OMV_READY
)
7281 fprintf (file
, " OMV_READY");
7282 if (val
& EIHD__M_EXT_BIND_SECT
)
7283 fprintf (file
, " EXT_BIND_SECT");
7284 fprintf (file
, "\n");
7285 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7286 "match ctrl: %u, symvect_size: %u\n"),
7287 (unsigned)bfd_getl32 (eihd
.ident
),
7288 (unsigned)bfd_getl32 (eihd
.sysver
),
7290 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7291 fprintf (file
, _(" BPAGE: %u"),
7292 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7293 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7295 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7296 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7297 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7298 eihef_off
, eihnp_off
);
7300 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7304 struct vms_eihvn eihvn
;
7308 fprintf (file
, _("system version array information:\n"));
7309 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7310 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7312 fprintf (file
, _("cannot read EIHVN header\n"));
7315 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7316 for (j
= 0; j
< 32; j
++)
7317 if (mask
& (1 << j
))
7319 struct vms_eihvn_subversion ver
;
7320 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7322 fprintf (file
, _("cannot read EIHVN version\n"));
7325 fprintf (file
, _(" %02u "), j
);
7328 case EIHVN__BASE_IMAGE_BIT
:
7329 fputs (_("BASE_IMAGE "), file
);
7331 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7332 fputs (_("MEMORY_MANAGEMENT"), file
);
7335 fputs (_("IO "), file
);
7337 case EIHVN__FILES_VOLUMES_BIT
:
7338 fputs (_("FILES_VOLUMES "), file
);
7340 case EIHVN__PROCESS_SCHED_BIT
:
7341 fputs (_("PROCESS_SCHED "), file
);
7343 case EIHVN__SYSGEN_BIT
:
7344 fputs (_("SYSGEN "), file
);
7346 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7347 fputs (_("CLUSTERS_LOCKMGR "), file
);
7349 case EIHVN__LOGICAL_NAMES_BIT
:
7350 fputs (_("LOGICAL_NAMES "), file
);
7352 case EIHVN__SECURITY_BIT
:
7353 fputs (_("SECURITY "), file
);
7355 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7356 fputs (_("IMAGE_ACTIVATOR "), file
);
7358 case EIHVN__NETWORKS_BIT
:
7359 fputs (_("NETWORKS "), file
);
7361 case EIHVN__COUNTERS_BIT
:
7362 fputs (_("COUNTERS "), file
);
7364 case EIHVN__STABLE_BIT
:
7365 fputs (_("STABLE "), file
);
7367 case EIHVN__MISC_BIT
:
7368 fputs (_("MISC "), file
);
7370 case EIHVN__CPU_BIT
:
7371 fputs (_("CPU "), file
);
7373 case EIHVN__VOLATILE_BIT
:
7374 fputs (_("VOLATILE "), file
);
7376 case EIHVN__SHELL_BIT
:
7377 fputs (_("SHELL "), file
);
7379 case EIHVN__POSIX_BIT
:
7380 fputs (_("POSIX "), file
);
7382 case EIHVN__MULTI_PROCESSING_BIT
:
7383 fputs (_("MULTI_PROCESSING "), file
);
7385 case EIHVN__GALAXY_BIT
:
7386 fputs (_("GALAXY "), file
);
7389 fputs (_("*unknown* "), file
);
7392 fprintf (file
, _(": %u.%u\n"),
7393 (unsigned)bfd_getl16 (ver
.major
),
7394 (unsigned)bfd_getl16 (ver
.minor
));
7400 struct vms_eiha eiha
;
7402 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7403 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7405 fprintf (file
, _("cannot read EIHA\n"));
7408 fprintf (file
, _("Image activation: (size=%u)\n"),
7409 (unsigned)bfd_getl32 (eiha
.size
));
7410 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7411 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7412 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7413 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7414 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7415 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7416 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7417 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7418 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7419 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7420 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7421 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7422 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7423 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7424 (unsigned)bfd_getl32 (eiha
.inishr
));
7428 struct vms_eihi eihi
;
7430 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7431 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7433 fprintf (file
, _("cannot read EIHI\n"));
7436 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7437 (unsigned)bfd_getl32 (eihi
.majorid
),
7438 (unsigned)bfd_getl32 (eihi
.minorid
));
7439 fprintf (file
, _(" image name : %.*s\n"),
7440 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7441 fprintf (file
, _(" link time : %s\n"),
7442 vms_time_to_str (eihi
.linktime
));
7443 fprintf (file
, _(" image ident : %.*s\n"),
7444 eihi
.imgid
[0], eihi
.imgid
+ 1);
7445 fprintf (file
, _(" linker ident : %.*s\n"),
7446 eihi
.linkid
[0], eihi
.linkid
+ 1);
7447 fprintf (file
, _(" image build ident: %.*s\n"),
7448 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7452 struct vms_eihs eihs
;
7454 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7455 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7457 fprintf (file
, _("cannot read EIHS\n"));
7460 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7461 (unsigned)bfd_getl32 (eihs
.majorid
),
7462 (unsigned)bfd_getl32 (eihs
.minorid
));
7463 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7464 dst_size
= bfd_getl32 (eihs
.dstsize
);
7465 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7466 dst_vbn
, dst_size
, dst_size
);
7467 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7468 gst_size
= bfd_getl32 (eihs
.gstsize
);
7469 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7471 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7472 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7473 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7476 while (eisd_off
!= 0)
7478 struct vms_eisd eisd
;
7483 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7484 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7486 fprintf (file
, _("cannot read EISD\n"));
7489 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7490 if (len
!= (unsigned)-1)
7494 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7496 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7497 "size: %u, offset: %u)\n"),
7498 (unsigned)bfd_getl32 (eisd
.majorid
),
7499 (unsigned)bfd_getl32 (eisd
.minorid
),
7503 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7504 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7505 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7506 (unsigned)bfd_getl32 (eisd
.secsize
));
7507 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7508 fprintf (file
, _(" flags: 0x%04x"), val
);
7509 if (val
& EISD__M_GBL
)
7510 fprintf (file
, " GBL");
7511 if (val
& EISD__M_CRF
)
7512 fprintf (file
, " CRF");
7513 if (val
& EISD__M_DZRO
)
7514 fprintf (file
, " DZRO");
7515 if (val
& EISD__M_WRT
)
7516 fprintf (file
, " WRT");
7517 if (val
& EISD__M_INITALCODE
)
7518 fprintf (file
, " INITALCODE");
7519 if (val
& EISD__M_BASED
)
7520 fprintf (file
, " BASED");
7521 if (val
& EISD__M_FIXUPVEC
)
7522 fprintf (file
, " FIXUPVEC");
7523 if (val
& EISD__M_RESIDENT
)
7524 fprintf (file
, " RESIDENT");
7525 if (val
& EISD__M_VECTOR
)
7526 fprintf (file
, " VECTOR");
7527 if (val
& EISD__M_PROTECT
)
7528 fprintf (file
, " PROTECT");
7529 if (val
& EISD__M_LASTCLU
)
7530 fprintf (file
, " LASTCLU");
7531 if (val
& EISD__M_EXE
)
7532 fprintf (file
, " EXE");
7533 if (val
& EISD__M_NONSHRADR
)
7534 fprintf (file
, " NONSHRADR");
7535 if (val
& EISD__M_QUAD_LENGTH
)
7536 fprintf (file
, " QUAD_LENGTH");
7537 if (val
& EISD__M_ALLOC_64BIT
)
7538 fprintf (file
, " ALLOC_64BIT");
7539 fprintf (file
, "\n");
7540 if (val
& EISD__M_FIXUPVEC
)
7542 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7543 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7545 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7546 (unsigned)bfd_getl32 (eisd
.vbn
),
7547 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7550 case EISD__K_NORMAL
:
7551 fputs (_("NORMAL"), file
);
7553 case EISD__K_SHRFXD
:
7554 fputs (_("SHRFXD"), file
);
7556 case EISD__K_PRVFXD
:
7557 fputs (_("PRVFXD"), file
);
7559 case EISD__K_SHRPIC
:
7560 fputs (_("SHRPIC"), file
);
7562 case EISD__K_PRVPIC
:
7563 fputs (_("PRVPIC"), file
);
7565 case EISD__K_USRSTACK
:
7566 fputs (_("USRSTACK"), file
);
7569 fputs (_("*unknown*"), file
);
7572 fputs (_(")\n"), file
);
7573 if (val
& EISD__M_GBL
)
7574 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7575 (unsigned)bfd_getl32 (eisd
.ident
),
7576 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7582 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7584 fprintf (file
, _("cannot read DMT\n"));
7588 fprintf (file
, _("Debug module table:\n"));
7590 while (dmt_size
> 0)
7592 struct vms_dmt_header dmth
;
7595 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7597 fprintf (file
, _("cannot read DMT header\n"));
7600 count
= bfd_getl16 (dmth
.psect_count
);
7602 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7603 (unsigned)bfd_getl32 (dmth
.modbeg
),
7604 (unsigned)bfd_getl32 (dmth
.size
), count
);
7605 dmt_size
-= sizeof (dmth
);
7608 struct vms_dmt_psect dmtp
;
7610 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7612 fprintf (file
, _("cannot read DMT psect\n"));
7615 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7616 (unsigned)bfd_getl32 (dmtp
.start
),
7617 (unsigned)bfd_getl32 (dmtp
.length
));
7619 dmt_size
-= sizeof (dmtp
);
7626 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7628 fprintf (file
, _("cannot read DST\n"));
7632 evax_bfd_print_dst (abfd
, dst_size
, file
);
7636 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7638 fprintf (file
, _("cannot read GST\n"));
7642 fprintf (file
, _("Global symbol table:\n"));
7643 evax_bfd_print_eobj (abfd
, file
);
7648 struct vms_eiaf
*eiaf
;
7649 unsigned int qrelfixoff
;
7650 unsigned int lrelfixoff
;
7651 unsigned int qdotadroff
;
7652 unsigned int ldotadroff
;
7653 unsigned int shrimgcnt
;
7654 unsigned int shlstoff
;
7655 unsigned int codeadroff
;
7656 unsigned int lpfixoff
;
7657 unsigned int chgprtoff
;
7659 buf
= bfd_malloc (eiaf_size
);
7661 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7662 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7664 fprintf (file
, _("cannot read EIHA\n"));
7668 eiaf
= (struct vms_eiaf
*)buf
;
7670 _("Image activator fixup: (major: %u, minor: %u)\n"),
7671 (unsigned)bfd_getl32 (eiaf
->majorid
),
7672 (unsigned)bfd_getl32 (eiaf
->minorid
));
7673 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7674 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7675 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7676 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7677 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7678 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7679 fprintf (file
, _(" size : %u\n"),
7680 (unsigned)bfd_getl32 (eiaf
->size
));
7681 fprintf (file
, _(" flags: 0x%08x\n"),
7682 (unsigned)bfd_getl32 (eiaf
->flags
));
7683 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7684 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7685 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7686 qrelfixoff
, lrelfixoff
);
7687 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7688 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7689 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7690 qdotadroff
, ldotadroff
);
7691 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7692 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7693 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7694 codeadroff
, lpfixoff
);
7695 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7696 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7697 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7698 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7699 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7700 shlstoff
, shrimgcnt
);
7701 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7702 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7703 (unsigned)bfd_getl32 (eiaf
->permctx
));
7704 fprintf (file
, _(" base_va : 0x%08x\n"),
7705 (unsigned)bfd_getl32 (eiaf
->base_va
));
7706 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7707 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7711 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7714 fprintf (file
, _(" Shareable images:\n"));
7715 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7718 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7719 j
, shl
->size
, shl
->flags
,
7720 shl
->imgnam
[0], shl
->imgnam
+ 1);
7723 if (qrelfixoff
!= 0)
7725 fprintf (file
, _(" quad-word relocation fixups:\n"));
7726 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7728 if (lrelfixoff
!= 0)
7730 fprintf (file
, _(" long-word relocation fixups:\n"));
7731 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
7733 if (qdotadroff
!= 0)
7735 fprintf (file
, _(" quad-word .address reference fixups:\n"));
7736 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
7738 if (ldotadroff
!= 0)
7740 fprintf (file
, _(" long-word .address reference fixups:\n"));
7741 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
7743 if (codeadroff
!= 0)
7745 fprintf (file
, _(" Code Address Reference Fixups:\n"));
7746 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
7750 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
7751 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
7755 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
7756 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
7759 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
7760 for (j
= 0; j
< count
; j
++, eicp
++)
7762 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
7764 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7765 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
7766 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
7767 (unsigned)bfd_getl32 (eicp
->size
),
7768 (unsigned)bfd_getl32 (eicp
->newprt
));
7772 fprintf (file
, "NA");
7774 case PRT__C_RESERVED
:
7775 fprintf (file
, "RES");
7778 fprintf (file
, "KW");
7781 fprintf (file
, "KR");
7784 fprintf (file
, "UW");
7787 fprintf (file
, "EW");
7790 fprintf (file
, "ERKW");
7793 fprintf (file
, "ER");
7796 fprintf (file
, "SW");
7799 fprintf (file
, "SREW");
7802 fprintf (file
, "SRKW");
7805 fprintf (file
, "SR");
7808 fprintf (file
, "URSW");
7811 fprintf (file
, "UREW");
7814 fprintf (file
, "URKW");
7817 fprintf (file
, "UR");
7831 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
7833 FILE *file
= (FILE *)ptr
;
7835 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
7836 evax_bfd_print_image (abfd
, file
);
7839 if (bfd_seek (abfd
, 0, SEEK_SET
))
7841 evax_bfd_print_eobj (abfd
, file
);
7848 /* Slurp ETIR/EDBG/ETBT VMS object records. */
7851 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
7853 asection
*cur_section
;
7854 file_ptr cur_offset
;
7855 asection
*dst_section
;
7856 file_ptr dst_offset
;
7858 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
7864 dst_section
= PRIV (dst_section
);
7868 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
7870 /* Discard the DST section. */
7874 else if (dst_section
)
7876 dst_offset
= dst_section
->output_offset
;
7877 dst_section
= dst_section
->output_section
;
7886 type
= _bfd_vms_get_object_record (abfd
);
7889 vms_debug2 ((2, "next_record failed\n"));
7895 PRIV (image_section
) = cur_section
;
7896 PRIV (image_offset
) = cur_offset
;
7897 res
= _bfd_vms_slurp_etir (abfd
, info
);
7898 cur_section
= PRIV (image_section
);
7899 cur_offset
= PRIV (image_offset
);
7903 if (dst_section
== NULL
)
7905 PRIV (image_section
) = dst_section
;
7906 PRIV (image_offset
) = dst_offset
;
7907 res
= _bfd_vms_slurp_etir (abfd
, info
);
7908 dst_offset
= PRIV (image_offset
);
7917 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
7924 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
7925 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7930 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
7933 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7935 struct alpha_vms_shlib_el
*sl
;
7936 asection
*sect
= PRIV2 (src
, image_section
);
7937 file_ptr offset
= PRIV2 (src
, image_offset
);
7939 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7940 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7941 sl
->has_fixups
= TRUE
;
7942 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
7943 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7944 sect
->output_section
->flags
|= SEC_RELOC
;
7947 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
7950 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7952 struct alpha_vms_shlib_el
*sl
;
7953 asection
*sect
= PRIV2 (src
, image_section
);
7954 file_ptr offset
= PRIV2 (src
, image_offset
);
7956 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7957 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7958 sl
->has_fixups
= TRUE
;
7959 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
7960 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7961 sect
->output_section
->flags
|= SEC_RELOC
;
7964 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
7967 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
7968 bfd
*shlib
, bfd_vma vec
)
7970 struct alpha_vms_shlib_el
*sl
;
7971 struct alpha_vms_vma_ref
*r
;
7972 asection
*sect
= PRIV2 (src
, image_section
);
7973 file_ptr offset
= PRIV2 (src
, image_offset
);
7975 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7976 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7977 sl
->has_fixups
= TRUE
;
7978 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
7979 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
7981 sect
->output_section
->flags
|= SEC_RELOC
;
7985 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
7986 unsigned int shr ATTRIBUTE_UNUSED
,
7987 bfd_vma vec ATTRIBUTE_UNUSED
)
7989 /* Not yet supported. */
7993 /* Add relocation. FIXME: Not yet emitted. */
7996 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8001 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8005 static struct bfd_hash_entry
*
8006 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8007 struct bfd_hash_table
*table
,
8010 struct alpha_vms_link_hash_entry
*ret
=
8011 (struct alpha_vms_link_hash_entry
*) entry
;
8013 /* Allocate the structure if it has not already been allocated by a
8016 ret
= ((struct alpha_vms_link_hash_entry
*)
8017 bfd_hash_allocate (table
,
8018 sizeof (struct alpha_vms_link_hash_entry
)));
8022 /* Call the allocation method of the superclass. */
8023 ret
= ((struct alpha_vms_link_hash_entry
*)
8024 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8029 return (struct bfd_hash_entry
*) ret
;
8032 /* Create an Alpha/VMS link hash table. */
8034 static struct bfd_link_hash_table
*
8035 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8037 struct alpha_vms_link_hash_table
*ret
;
8038 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8040 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8043 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8044 alpha_vms_link_hash_newfunc
,
8045 sizeof (struct alpha_vms_link_hash_entry
)))
8051 VEC_INIT (ret
->shrlibs
);
8058 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8062 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8064 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8065 struct alpha_vms_link_hash_entry
*h
;
8066 struct bfd_link_hash_entry
*h_root
;
8069 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8072 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8074 /* In selective_search mode, only add definition that are
8076 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8077 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8078 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8084 h_root
= (struct bfd_link_hash_entry
*) h
;
8085 if (_bfd_generic_link_add_one_symbol
8086 (info
, abfd
, sym
.name
, sym
.flags
, sym
.section
, sym
.value
,
8087 NULL
, FALSE
, FALSE
, &h_root
) == FALSE
)
8089 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8091 if ((e
->flags
& EGSY__V_DEF
)
8093 && abfd
->xvec
== info
->output_bfd
->xvec
)
8097 if (abfd
->flags
& DYNAMIC
)
8099 struct alpha_vms_shlib_el
*shlib
;
8101 /* We do not want to include any of the sections in a dynamic
8102 object in the output file. See comment in elflink.c. */
8103 bfd_section_list_clear (abfd
);
8105 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8106 struct alpha_vms_shlib_el
);
8108 VEC_INIT (shlib
->ca
);
8109 VEC_INIT (shlib
->lp
);
8110 VEC_INIT (shlib
->qr
);
8111 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8118 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8121 struct bfd_link_hash_entry
**pundef
;
8122 struct bfd_link_hash_entry
**next_pundef
;
8124 /* We only accept VMS libraries. */
8125 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8127 bfd_set_error (bfd_error_wrong_format
);
8131 /* The archive_pass field in the archive itself is used to
8132 initialize PASS, since we may search the same archive multiple
8134 pass
= ++abfd
->archive_pass
;
8136 /* Look through the list of undefined symbols. */
8137 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8139 struct bfd_link_hash_entry
*h
;
8145 next_pundef
= &(*pundef
)->u
.undef
.next
;
8147 /* When a symbol is defined, it is not necessarily removed from
8149 if (h
->type
!= bfd_link_hash_undefined
8150 && h
->type
!= bfd_link_hash_common
)
8152 /* Remove this entry from the list, for general cleanliness
8153 and because we are going to look through the list again
8154 if we search any more libraries. We can't remove the
8155 entry if it is the tail, because that would lose any
8156 entries we add to the list later on. */
8157 if (*pundef
!= info
->hash
->undefs_tail
)
8159 *pundef
= *next_pundef
;
8160 next_pundef
= pundef
;
8165 /* Look for this symbol in the archive hash table. */
8166 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8167 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8169 /* Nothing in this slot. */
8173 element
= bfd_get_elt_at_index (abfd
, symidx
);
8174 if (element
== NULL
)
8177 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8179 /* Next symbol if this archive is wrong or already handled. */
8183 if (! bfd_check_format (element
, bfd_object
))
8185 element
->archive_pass
= -1;
8189 orig_element
= element
;
8190 if (bfd_is_thin_archive (abfd
))
8192 element
= _bfd_vms_lib_get_imagelib_file (element
);
8193 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8195 orig_element
->archive_pass
= -1;
8200 /* Unlike the generic linker, we know that this element provides
8201 a definition for an undefined symbol and we know that we want
8202 to include it. We don't need to check anything. */
8203 if (!(*info
->callbacks
8204 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8206 if (!alpha_vms_link_add_object_symbols (element
, info
))
8209 orig_element
->archive_pass
= pass
;
8216 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8218 switch (bfd_get_format (abfd
))
8221 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8223 return alpha_vms_link_add_object_symbols (abfd
, info
);
8226 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8228 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8231 bfd_set_error (bfd_error_wrong_format
);
8237 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8239 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8240 unsigned char *content
;
8242 unsigned int sz
= 0;
8243 unsigned int lp_sz
= 0;
8244 unsigned int ca_sz
= 0;
8245 unsigned int qr_sz
= 0;
8246 unsigned int shrimg_cnt
= 0;
8247 unsigned int chgprt_num
= 0;
8248 unsigned int chgprt_sz
= 0;
8249 struct vms_eiaf
*eiaf
;
8253 /* Shared libraries. */
8254 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8256 struct alpha_vms_shlib_el
*shlib
;
8258 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8260 if (!shlib
->has_fixups
)
8265 if (VEC_COUNT (shlib
->ca
) > 0)
8267 /* Header + entries. */
8269 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8271 if (VEC_COUNT (shlib
->lp
) > 0)
8273 /* Header + entries. */
8275 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8277 if (VEC_COUNT (shlib
->qr
) > 0)
8279 /* Header + entries. */
8281 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8292 /* Finish now if there is no content. */
8293 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8296 /* Add an eicp entry for the fixup itself. */
8298 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8300 /* This isect could be made RO or EXE after relocations are applied. */
8301 if ((sec
->flags
& SEC_RELOC
) != 0
8302 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8305 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8307 /* Allocate section content (round-up size) */
8308 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8309 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8310 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8311 content
= bfd_zalloc (info
->output_bfd
, sz
);
8312 if (content
== NULL
)
8315 sec
= alpha_vms_link_hash (info
)->fixup
;
8316 sec
->contents
= content
;
8319 eiaf
= (struct vms_eiaf
*)content
;
8320 off
= sizeof (struct vms_eiaf
);
8321 bfd_putl32 (0, eiaf
->majorid
);
8322 bfd_putl32 (0, eiaf
->minorid
);
8323 bfd_putl32 (0, eiaf
->iaflink
);
8324 bfd_putl32 (0, eiaf
->fixuplnk
);
8325 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8326 bfd_putl32 (0, eiaf
->flags
);
8327 bfd_putl32 (0, eiaf
->qrelfixoff
);
8328 bfd_putl32 (0, eiaf
->lrelfixoff
);
8329 bfd_putl32 (0, eiaf
->qdotadroff
);
8330 bfd_putl32 (0, eiaf
->ldotadroff
);
8331 bfd_putl32 (0, eiaf
->codeadroff
);
8332 bfd_putl32 (0, eiaf
->lpfixoff
);
8333 bfd_putl32 (0, eiaf
->chgprtoff
);
8334 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8335 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8336 bfd_putl32 (0, eiaf
->shlextra
);
8337 bfd_putl32 (0, eiaf
->permctx
);
8338 bfd_putl32 (0, eiaf
->base_va
);
8339 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8346 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8348 struct alpha_vms_shlib_el
*shlib
;
8349 struct vms_shl
*shl
;
8351 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8353 if (!shlib
->has_fixups
)
8356 /* Renumber shared images. */
8357 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8359 shl
= (struct vms_shl
*)(content
+ off
);
8360 bfd_putl32 (0, shl
->baseva
);
8361 bfd_putl32 (0, shl
->shlptr
);
8362 bfd_putl32 (0, shl
->ident
);
8363 bfd_putl32 (0, shl
->permctx
);
8364 shl
->size
= sizeof (struct vms_shl
);
8365 bfd_putl16 (0, shl
->fill_1
);
8367 bfd_putl32 (0, shl
->icb
);
8368 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8369 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8372 off
+= sizeof (struct vms_shl
);
8378 bfd_putl32 (off
, eiaf
->codeadroff
);
8380 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8382 struct alpha_vms_shlib_el
*shlib
;
8385 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8387 if (VEC_COUNT (shlib
->ca
) == 0)
8390 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8391 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8394 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8396 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8402 bfd_putl32 (0, content
+ off
);
8403 bfd_putl32 (0, content
+ off
+ 4);
8410 bfd_putl32 (off
, eiaf
->lpfixoff
);
8412 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8414 struct alpha_vms_shlib_el
*shlib
;
8417 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8419 if (VEC_COUNT (shlib
->lp
) == 0)
8422 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8423 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8426 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8428 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8434 bfd_putl32 (0, content
+ off
);
8435 bfd_putl32 (0, content
+ off
+ 4);
8442 bfd_putl32 (off
, eiaf
->qdotadroff
);
8444 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8446 struct alpha_vms_shlib_el
*shlib
;
8449 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8451 if (VEC_COUNT (shlib
->qr
) == 0)
8454 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8455 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8458 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8460 struct alpha_vms_vma_ref
*r
;
8461 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8462 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8463 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8468 bfd_putl32 (0, content
+ off
);
8469 bfd_putl32 (0, content
+ off
+ 4);
8474 /* Write the change protection table. */
8475 bfd_putl32 (off
, eiaf
->chgprtoff
);
8476 bfd_putl32 (chgprt_num
, content
+ off
);
8479 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8481 struct vms_eicp
*eicp
;
8484 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8485 strcmp (sec
->name
, "$FIXUP$") == 0)
8487 else if ((sec
->flags
& SEC_RELOC
) != 0
8488 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8493 eicp
= (struct vms_eicp
*)(content
+ off
);
8494 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8495 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8497 bfd_putl32 (prot
, eicp
->newprt
);
8498 off
+= sizeof (struct vms_eicp
);
8504 /* Called by bfd_hash_traverse to fill the symbol table.
8505 Return FALSE in case of failure. */
8508 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8510 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8511 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8512 struct alpha_vms_link_hash_entry
*h
;
8513 struct vms_symbol_entry
*sym
;
8515 if (hc
->type
== bfd_link_hash_warning
)
8518 if (hc
->type
== bfd_link_hash_new
)
8521 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8523 switch (h
->root
.type
)
8525 case bfd_link_hash_undefined
:
8527 case bfd_link_hash_new
:
8528 case bfd_link_hash_warning
:
8530 case bfd_link_hash_undefweak
:
8532 case bfd_link_hash_defined
:
8533 case bfd_link_hash_defweak
:
8535 asection
*sec
= h
->root
.u
.def
.section
;
8537 /* FIXME: this is certainly a symbol from a dynamic library. */
8538 if (bfd_is_abs_section (sec
))
8541 if (sec
->owner
->flags
& DYNAMIC
)
8545 case bfd_link_hash_common
:
8547 case bfd_link_hash_indirect
:
8551 /* Do not write not kept symbols. */
8552 if (info
->strip
== strip_some
8553 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8554 FALSE
, FALSE
) != NULL
)
8559 /* This symbol doesn't come from a VMS object. So we suppose it is
8561 int len
= strlen (h
->root
.root
.string
);
8563 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8564 sizeof (*sym
) + len
);
8568 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8570 sym
->owner
= info
->output_bfd
;
8572 sym
->typ
= EGSD__C_SYMG
;
8574 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8575 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8576 sym
->section
= h
->root
.u
.def
.section
;
8577 sym
->value
= h
->root
.u
.def
.value
;
8582 if (!add_symbol_entry (info
->output_bfd
, sym
))
8589 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8592 struct bfd_link_order
*p
;
8600 if (info
->relocatable
)
8602 /* FIXME: we do not yet support relocatable link. It is not obvious
8603 how to do it for debug infos. */
8604 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8608 bfd_get_outsymbols (abfd
) = NULL
;
8609 bfd_get_symcount (abfd
) = 0;
8611 /* Mark all sections which will be included in the output file. */
8612 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8613 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8614 if (p
->type
== bfd_indirect_link_order
)
8615 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8618 /* Handle all the link order information for the sections. */
8619 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8621 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8622 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8624 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8626 printf (" at 0x%08x - 0x%08x: ",
8627 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8630 case bfd_section_reloc_link_order
:
8631 case bfd_symbol_reloc_link_order
:
8632 printf (" section/symbol reloc\n");
8634 case bfd_indirect_link_order
:
8635 printf (" section %s of %s\n",
8636 p
->u
.indirect
.section
->name
,
8637 p
->u
.indirect
.section
->owner
->filename
);
8639 case bfd_data_link_order
:
8640 printf (" explicit data\n");
8643 printf (" *unknown* type %u\n", p
->type
);
8650 /* Generate the symbol table. */
8651 BFD_ASSERT (PRIV (syms
) == NULL
);
8652 if (info
->strip
!= strip_all
)
8653 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
8655 /* Find the entry point. */
8656 if (bfd_get_start_address (abfd
) == 0)
8658 bfd
*startbfd
= NULL
;
8660 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8662 /* Consider only VMS object files. */
8663 if (sub
->xvec
!= abfd
->xvec
)
8666 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8668 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8670 if (startbfd
!= NULL
8671 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8673 (*info
->callbacks
->einfo
)
8674 (_("%P: multiple entry points: in modules %B and %B\n"),
8683 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8684 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8687 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8689 bfd_set_start_address
8690 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8694 /* Set transfer addresses. */
8697 struct bfd_link_hash_entry
*h
;
8700 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
8701 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
8702 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
8703 PRIV (transfer_address
[i
++]) =
8704 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
8705 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
8707 PRIV (transfer_address
[i
++]) = 0;
8710 /* Allocate contents.
8711 Also compute the virtual base address. */
8712 base_addr
= (bfd_vma
)-1;
8714 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8716 if (o
->flags
& SEC_HAS_CONTENTS
)
8718 o
->contents
= bfd_alloc (abfd
, o
->size
);
8719 if (o
->contents
== NULL
)
8722 if (o
->flags
& SEC_LOAD
)
8724 if (o
->vma
< base_addr
)
8726 if (o
->vma
+ o
->size
> last_addr
)
8727 last_addr
= o
->vma
+ o
->size
;
8729 /* Clear the RELOC flags. Currently we don't support incremental
8730 linking. We use the RELOC flag for computing the eicp entries. */
8731 o
->flags
&= ~SEC_RELOC
;
8734 /* Create the fixup section. */
8735 fixupsec
= bfd_make_section_anyway_with_flags
8736 (info
->output_bfd
, "$FIXUP$",
8737 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8738 if (fixupsec
== NULL
)
8740 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
8741 fixupsec
->vma
= last_addr
;
8743 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
8744 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
8746 /* Create the DMT section, if necessary. */
8747 BFD_ASSERT (PRIV (dst_section
) == NULL
);
8748 dst
= bfd_get_section_by_name (abfd
, "$DST$");
8749 if (dst
!= NULL
&& dst
->size
== 0)
8753 PRIV (dst_section
) = dst
;
8754 dmt
= bfd_make_section_anyway_with_flags
8755 (info
->output_bfd
, "$DMT$",
8756 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8763 /* Read all sections from the inputs. */
8764 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8766 if (sub
->flags
& DYNAMIC
)
8768 alpha_vms_create_eisd_for_shared (abfd
, sub
);
8772 if (!alpha_vms_read_sections_content (sub
, info
))
8776 /* Handle all the link order information for the sections.
8777 Note: past this point, it is not possible to create new sections. */
8778 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8780 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8784 case bfd_section_reloc_link_order
:
8785 case bfd_symbol_reloc_link_order
:
8788 case bfd_indirect_link_order
:
8792 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
8799 /* Compute fixups. */
8800 if (!alpha_vms_build_fixups (info
))
8803 /* Compute the DMT. */
8807 unsigned char *contents
= NULL
;
8809 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
8810 for (pass
= 0; pass
< 2; pass
++)
8812 unsigned int off
= 0;
8814 /* For each object file (ie for each module). */
8815 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8818 struct vms_dmt_header
*dmth
= NULL
;
8819 unsigned int psect_count
;
8821 /* Skip this module if it has no DST. */
8822 sub_dst
= PRIV2 (sub
, dst_section
);
8823 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
8828 /* Write the header. */
8829 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
8830 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
8831 bfd_putl32 (sub_dst
->size
, dmth
->size
);
8834 off
+= sizeof (struct vms_dmt_header
);
8837 /* For each section (ie for each psect). */
8838 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8840 /* Only consider interesting sections. */
8841 if (!(o
->flags
& SEC_ALLOC
))
8843 if (o
->flags
& SEC_LINKER_CREATED
)
8848 /* Write an entry. */
8849 struct vms_dmt_psect
*dmtp
;
8851 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
8852 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
8854 bfd_putl32 (o
->size
, dmtp
->length
);
8857 off
+= sizeof (struct vms_dmt_psect
);
8860 bfd_putl32 (psect_count
, dmth
->psect_count
);
8865 contents
= bfd_zalloc (info
->output_bfd
, off
);
8866 if (contents
== NULL
)
8868 dmt
->contents
= contents
;
8873 BFD_ASSERT (off
== dmt
->size
);
8881 /* Read the contents of a section.
8882 buf points to a buffer of buf_size bytes to be filled with
8883 section data (starting at offset into section) */
8886 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
8887 void *buf
, file_ptr offset
,
8888 bfd_size_type count
)
8892 /* Image are easy. */
8893 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8894 return _bfd_generic_get_section_contents (abfd
, section
,
8895 buf
, offset
, count
);
8898 if (offset
+ count
< count
8899 || offset
+ count
> section
->size
)
8901 bfd_set_error (bfd_error_invalid_operation
);
8905 /* If the section is already in memory, just copy it. */
8906 if (section
->flags
& SEC_IN_MEMORY
)
8908 BFD_ASSERT (section
->contents
!= NULL
);
8909 memcpy (buf
, section
->contents
+ offset
, count
);
8912 if (section
->size
== 0)
8915 /* Alloc in memory and read ETIRs. */
8916 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8918 BFD_ASSERT (sec
->contents
== NULL
);
8920 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
8922 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
8923 if (sec
->contents
== NULL
)
8927 if (!alpha_vms_read_sections_content (abfd
, NULL
))
8929 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8931 sec
->flags
|= SEC_IN_MEMORY
;
8932 memcpy (buf
, section
->contents
+ offset
, count
);
8937 /* Set the format of a file being written. */
8940 alpha_vms_mkobject (bfd
* abfd
)
8942 const bfd_arch_info_type
*arch
;
8944 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
8946 if (!vms_initialize (abfd
))
8949 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
8950 if (PRIV (recwr
.buf
) == NULL
)
8953 arch
= bfd_scan_arch ("alpha");
8957 bfd_set_error (bfd_error_wrong_format
);
8961 abfd
->arch_info
= arch
;
8968 /* Called when the BFD is being closed to do any necessary cleanup. */
8971 vms_close_and_cleanup (bfd
* abfd
)
8973 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
8975 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
8978 if (abfd
->format
== bfd_archive
)
8980 bfd_release (abfd
, abfd
->tdata
.any
);
8981 abfd
->tdata
.any
= NULL
;
8985 if (PRIV (recrd
.buf
) != NULL
)
8986 free (PRIV (recrd
.buf
));
8988 if (PRIV (sections
) != NULL
)
8989 free (PRIV (sections
));
8991 bfd_release (abfd
, abfd
->tdata
.any
);
8992 abfd
->tdata
.any
= NULL
;
8995 if (abfd
->direction
== write_direction
)
8997 /* Last step on VMS is to convert the file to variable record length
8999 if (bfd_cache_close (abfd
) != TRUE
)
9001 if (_bfd_vms_convert_to_var_unix_filename (abfd
->filename
) != TRUE
)
9009 /* Called when a new section is created. */
9012 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9016 vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n",
9017 abfd
, section
->index
, section
->name
));
9019 if (! bfd_set_section_alignment (abfd
, section
, 0))
9022 vms_debug2 ((7, "%d: %s\n", section
->index
, section
->name
));
9024 amt
= sizeof (struct vms_section_data_struct
);
9025 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9026 if (section
->used_by_bfd
== NULL
)
9029 /* Create the section symbol. */
9030 return _bfd_generic_new_section_hook (abfd
, section
);
9033 /* Part 4.5, symbols. */
9035 /* Print symbol to file according to how. how is one of
9036 bfd_print_symbol_name just print the name
9037 bfd_print_symbol_more print more (???)
9038 bfd_print_symbol_all print all we know, which is not much right now :-). */
9041 vms_print_symbol (bfd
* abfd
,
9044 bfd_print_symbol_type how
)
9046 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9047 abfd
, file
, symbol
, how
));
9051 case bfd_print_symbol_name
:
9052 case bfd_print_symbol_more
:
9053 fprintf ((FILE *)file
," %s", symbol
->name
);
9056 case bfd_print_symbol_all
:
9058 const char *section_name
= symbol
->section
->name
;
9060 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9062 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9068 /* Return information about symbol in ret.
9070 fill type, value and name
9073 B bss segment symbol
9075 D data segment symbol
9077 t a static function symbol
9078 T text segment symbol
9083 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9089 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9091 sec
= symbol
->section
;
9098 else if (bfd_is_com_section (sec
))
9100 else if (bfd_is_abs_section (sec
))
9102 else if (bfd_is_und_section (sec
))
9104 else if (bfd_is_ind_section (sec
))
9106 else if ((symbol
->flags
& BSF_FUNCTION
)
9107 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9109 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9111 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9116 if (ret
->type
!= 'U')
9117 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9120 ret
->name
= symbol
->name
;
9123 /* Return TRUE if the given symbol sym in the BFD abfd is
9124 a compiler generated local label, else return FALSE. */
9127 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9130 return name
[0] == '$';
9133 /* Part 4.7, writing an object file. */
9135 /* Sets the contents of the section section in BFD abfd to the data starting
9136 in memory at LOCATION. The data is written to the output section starting
9137 at offset offset for count bytes.
9139 Normally TRUE is returned, else FALSE. Possible error returns are:
9140 o bfd_error_no_contents - The output section does not have the
9141 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9142 o and some more too */
9145 _bfd_vms_set_section_contents (bfd
* abfd
,
9147 const void * location
,
9149 bfd_size_type count
)
9151 if (section
->contents
== NULL
)
9153 section
->contents
= bfd_alloc (abfd
, section
->size
);
9154 if (section
->contents
== NULL
)
9157 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9163 /* Set the architecture and machine type in BFD abfd to arch and mach.
9164 Find the correct pointer to a structure and insert it into the arch_info
9168 alpha_vms_set_arch_mach (bfd
*abfd
,
9169 enum bfd_architecture arch
, unsigned long mach
)
9171 if (arch
!= bfd_arch_alpha
9172 && arch
!= bfd_arch_unknown
)
9175 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9178 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9181 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9182 asection
*sec
, flagword no_flags
, flagword flags
)
9184 vms_section_data (sec
)->no_flags
= no_flags
;
9185 vms_section_data (sec
)->flags
= flags
;
9188 struct vms_private_data_struct
*
9189 bfd_vms_get_data (bfd
*abfd
)
9191 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9194 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9195 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9196 #define vms_bfd_copy_link_hash_symbol_type \
9197 _bfd_generic_copy_link_hash_symbol_type
9198 #define vms_bfd_is_group_section bfd_generic_is_group_section
9199 #define vms_bfd_discard_group bfd_generic_discard_group
9200 #define vms_section_already_linked _bfd_generic_section_already_linked
9201 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9202 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9204 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9205 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9206 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9207 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9208 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9209 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9211 /* Symbols table. */
9212 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9213 #define alpha_vms_bfd_is_target_special_symbol \
9214 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9215 #define alpha_vms_print_symbol vms_print_symbol
9216 #define alpha_vms_get_symbol_info vms_get_symbol_info
9217 #define alpha_vms_get_symbol_version_string \
9218 _bfd_nosymbols_get_symbol_version_string
9220 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9221 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9222 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9223 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9224 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9225 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_line
9226 #define alpha_vms_find_line _bfd_nosymbols_find_line
9227 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9229 /* Generic table. */
9230 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9231 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9232 #define alpha_vms_new_section_hook vms_new_section_hook
9233 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9234 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9236 #define alpha_vms_bfd_get_relocated_section_contents \
9237 bfd_generic_get_relocated_section_contents
9239 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9240 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9241 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9242 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9243 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9244 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9245 #define alpha_vms_section_already_linked \
9246 _bfd_generic_section_already_linked
9248 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9249 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9250 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9251 _bfd_generic_copy_link_hash_symbol_type
9253 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9255 #define alpha_vms_get_dynamic_symtab_upper_bound \
9256 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9257 #define alpha_vms_canonicalize_dynamic_symtab \
9258 _bfd_nodynamic_canonicalize_dynamic_symtab
9259 #define alpha_vms_get_dynamic_reloc_upper_bound \
9260 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9261 #define alpha_vms_canonicalize_dynamic_reloc \
9262 _bfd_nodynamic_canonicalize_dynamic_reloc
9264 const bfd_target alpha_vms_vec
=
9266 "vms-alpha", /* Name. */
9267 bfd_target_evax_flavour
,
9268 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9269 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9271 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9272 | WP_TEXT
| D_PAGED
), /* Object flags. */
9273 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9274 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9275 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9276 0, /* symbol_leading_char. */
9277 ' ', /* ar_pad_char. */
9278 15, /* ar_max_namelen. */
9279 0, /* match priority. */
9280 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9281 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9282 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9283 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9284 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9285 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9287 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9288 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9289 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9290 _bfd_vms_lib_alpha_mkarchive
, bfd_false
},
9291 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9292 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9294 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9295 BFD_JUMP_TABLE_COPY (vms
),
9296 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9297 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9298 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9299 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9300 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9301 BFD_JUMP_TABLE_LINK (alpha_vms
),
9302 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),