1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
6 Major rewrite by Adacore.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
26 o Generation of shared image
27 o Relocation optimizations
33 o protected sections (for messages)
51 #include "vms/eihvn.h"
52 #include "vms/eobjrec.h"
55 #include "vms/esgps.h"
64 #include "vms/esdfm.h"
65 #include "vms/esdfv.h"
71 #include "vms/internal.h"
74 #define MIN(a,b) ((a) < (b) ? (a) : (b))
76 /* The r_type field in a reloc is one of the following values. */
77 #define ALPHA_R_IGNORE 0
78 #define ALPHA_R_REFQUAD 1
79 #define ALPHA_R_BRADDR 2
80 #define ALPHA_R_HINT 3
81 #define ALPHA_R_SREL16 4
82 #define ALPHA_R_SREL32 5
83 #define ALPHA_R_SREL64 6
84 #define ALPHA_R_OP_PUSH 7
85 #define ALPHA_R_OP_STORE 8
86 #define ALPHA_R_OP_PSUB 9
87 #define ALPHA_R_OP_PRSHIFT 10
88 #define ALPHA_R_LINKAGE 11
89 #define ALPHA_R_REFLONG 12
90 #define ALPHA_R_CODEADDR 13
91 #define ALPHA_R_NOP 14
92 #define ALPHA_R_BSR 15
93 #define ALPHA_R_LDA 16
94 #define ALPHA_R_BOH 17
96 /* These are used with DST_S_C_LINE_NUM. */
97 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
99 /* These are used with DST_S_C_SOURCE */
101 #define DST_S_B_PCLINE_UNSBYTE 1
102 #define DST_S_W_PCLINE_UNSWORD 1
103 #define DST_S_L_PCLINE_UNSLONG 1
105 #define DST_S_B_MODBEG_NAME 14
106 #define DST_S_L_RTNBEG_ADDRESS 5
107 #define DST_S_B_RTNBEG_NAME 13
108 #define DST_S_L_RTNEND_SIZE 5
110 /* These are used with DST_S_C_SOURCE. */
111 #define DST_S_C_SOURCE_HEADER_SIZE 4
113 #define DST_S_B_SRC_DF_LENGTH 1
114 #define DST_S_W_SRC_DF_FILEID 3
115 #define DST_S_B_SRC_DF_FILENAME 20
116 #define DST_S_B_SRC_UNSBYTE 1
117 #define DST_S_W_SRC_UNSWORD 1
118 #define DST_S_L_SRC_UNSLONG 1
120 /* Debugger symbol definitions. */
122 #define DBG_S_L_DMT_MODBEG 0
123 #define DBG_S_L_DST_SIZE 4
124 #define DBG_S_W_DMT_PSECT_COUNT 8
125 #define DBG_S_C_DMT_HEADER_SIZE 12
127 #define DBG_S_L_DMT_PSECT_START 0
128 #define DBG_S_L_DMT_PSECT_LENGTH 4
129 #define DBG_S_C_DMT_PSECT_SIZE 8
131 /* VMS module header. */
147 #define EMH_DATE_LENGTH 17
149 /* VMS End-Of-Module records (EOM/EEOM). */
153 unsigned int eom_l_total_lps
;
154 unsigned short eom_w_comcod
;
155 bfd_boolean eom_has_transfer
;
156 unsigned char eom_b_tfrflg
;
157 unsigned int eom_l_psindx
;
158 unsigned int eom_l_tfradr
;
161 struct vms_symbol_entry
167 unsigned char data_type
;
168 unsigned short flags
;
170 /* Section and offset/value of the symbol. */
174 /* Section and offset/value for the entry point (only for subprg). */
175 asection
*code_section
;
176 unsigned int code_value
;
178 /* Symbol vector offset. */
179 unsigned int symbol_vector
;
181 /* Length of the name. */
182 unsigned char namelen
;
187 /* Stack value for push/pop commands. */
195 #define STACKSIZE 128
197 /* A minimal decoding of DST compilation units. We only decode
198 what's needed to get to the line number information. */
208 struct srecinfo
*next
;
216 struct lineinfo
*next
;
223 struct funcinfo
*next
;
231 /* Chain the previously read compilation unit. */
234 /* The module name. */
237 /* The start offset and size of debug info in the DST section. */
241 /* The lowest and highest addresses contained in this compilation
242 unit as specified in the compilation unit header. */
246 /* The listing line table. */
247 struct lineinfo
*line_table
;
249 /* The source record table. */
250 struct srecinfo
*srec_table
;
252 /* A list of the functions found in this module. */
253 struct funcinfo
*func_table
;
255 /* Current allocation of file_table. */
256 unsigned int file_table_count
;
258 /* An array of the files making up this module. */
259 struct fileinfo
*file_table
;
262 /* BFD private data for alpha-vms. */
264 struct vms_private_data_struct
266 /* If true, relocs have been read. */
267 bfd_boolean reloc_done
;
269 /* Record input buffer. */
270 struct vms_rec_rd recrd
;
271 struct vms_rec_wr recwr
;
273 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
274 struct eom_struct eom_data
; /* data from EOM/EEOM record */
276 /* Transfer addresses (entry points). */
277 bfd_vma transfer_address
[4];
279 /* Array of GSD sections to get the correspond BFD one. */
280 unsigned int section_max
; /* Size of the sections array. */
281 unsigned int section_count
; /* Number of GSD sections. */
284 /* Array of raw symbols. */
285 struct vms_symbol_entry
**syms
;
287 /* Canonicalized symbols. */
290 /* Number of symbols. */
291 unsigned int gsd_sym_count
;
292 /* Size of the syms array. */
293 unsigned int max_sym_count
;
294 /* Number of procedure symbols. */
295 unsigned int norm_sym_count
;
297 /* Stack used to evaluate TIR/ETIR commands. */
298 struct stack_struct
*stack
;
301 /* Content reading. */
302 asection
*image_section
; /* section for image_ptr */
303 file_ptr image_offset
; /* Offset for image_ptr. */
305 struct module
*modules
; /* list of all compilation units */
307 /* The DST section. */
308 asection
*dst_section
;
310 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
311 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
313 /* Shared library support */
314 bfd_vma symvva
; /* relative virtual address of symbol vector */
316 unsigned char matchctl
;
318 /* Shared library index. This is used for input bfd while linking. */
319 unsigned int shr_index
;
321 /* Used to place structures in the file. */
324 /* Simply linked list of eisd. */
325 struct vms_internal_eisd_map
*eisd_head
;
326 struct vms_internal_eisd_map
*eisd_tail
;
328 /* Simply linked list of eisd for shared libraries. */
329 struct vms_internal_eisd_map
*gbl_eisd_head
;
330 struct vms_internal_eisd_map
*gbl_eisd_tail
;
332 /* linkage index counter used by conditional store commands */
333 int vms_linkage_index
;
335 /* see tc-alpha.c of gas for a description. */
336 int flag_hash_long_names
; /* -+, hash instead of truncate */
337 int flag_show_after_trunc
; /* -H, show hashing/truncation */
340 #define PRIV2(abfd, name) \
341 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
342 #define PRIV(name) PRIV2(abfd,name)
345 /* Used to keep extra VMS specific information for a given section.
347 reloc_size holds the size of the relocation stream, note this
348 is very different from the number of relocations as VMS relocations
351 reloc_stream is the actual stream of relocation entries. */
353 struct vms_section_data_struct
355 /* Maximnum number of entries in sec->relocation. */
358 /* Corresponding eisd. Used only while generating executables. */
359 struct vms_internal_eisd_map
*eisd
;
361 /* PSC flags to be clear. */
364 /* PSC flags to be set. */
368 #define vms_section_data(sec) \
369 ((struct vms_section_data_struct *)sec->used_by_bfd)
371 /* To be called from the debugger. */
372 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*abfd
);
374 static int vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
);
375 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
376 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
377 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
378 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
380 static void alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
382 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*info
);
383 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*info
);
392 /* Number of elements in VEC. */
394 #define VEC_COUNT(VEC) ((VEC).nbr_el)
396 /* Get the address of the Nth element. */
398 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
400 #define VEC_INIT(VEC) \
407 /* Be sure there is room for a new element. */
409 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
411 /* Allocate room for a new element and return its address. */
413 #define VEC_APPEND(VEC, TYPE) \
414 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
416 /* Append an element. */
418 #define VEC_APPEND_EL(VEC, TYPE, EL) \
419 (*(VEC_APPEND (VEC, TYPE)) = EL)
421 struct alpha_vms_vma_ref
423 bfd_vma vma
; /* Vma in the output. */
424 bfd_vma ref
; /* Reference in the input. */
427 struct alpha_vms_shlib_el
430 bfd_boolean has_fixups
;
432 struct vector_type lp
; /* Vector of bfd_vma. */
433 struct vector_type ca
; /* Vector of bfd_vma. */
434 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
437 /* Alpha VMS linker hash table. */
439 struct alpha_vms_link_hash_table
441 struct bfd_link_hash_table root
;
443 /* Vector of shared libaries. */
444 struct vector_type shrlibs
;
449 /* Base address. Used by fixups. */
453 #define alpha_vms_link_hash(INFO) \
454 ((struct alpha_vms_link_hash_table *)(INFO->hash))
456 /* Alpha VMS linker hash table entry. */
458 struct alpha_vms_link_hash_entry
460 struct bfd_link_hash_entry root
;
462 /* Pointer to the original vms symbol. */
463 struct vms_symbol_entry
*sym
;
468 /* Read & process EIHD record.
469 Return TRUE on success, FALSE on error. */
472 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
473 unsigned int *eihs_offset
)
475 unsigned int imgtype
, size
;
477 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
479 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
481 size
= bfd_getl32 (eihd
->size
);
482 imgtype
= bfd_getl32 (eihd
->imgtype
);
484 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
485 abfd
->flags
|= EXEC_P
;
487 symvva
= bfd_getl64 (eihd
->symvva
);
490 PRIV (symvva
) = symvva
;
491 abfd
->flags
|= DYNAMIC
;
494 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
495 PRIV (matchctl
) = eihd
->matchctl
;
497 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
498 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
500 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
501 size
, imgtype
, (unsigned long)symvva
,
502 *eisd_offset
, *eihs_offset
));
507 /* Read & process EISD record.
508 Return TRUE on success, FALSE on error. */
511 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
513 int section_count
= 0;
515 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
519 struct vms_eisd
*eisd
;
520 unsigned int rec_size
;
522 unsigned long long vaddr
;
529 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
530 rec_size
= bfd_getl32 (eisd
->eisdsize
);
535 /* Skip to next block if pad. */
536 if (rec_size
== 0xffffffff)
538 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
544 size
= bfd_getl32 (eisd
->secsize
);
545 vaddr
= bfd_getl64 (eisd
->virt_addr
);
546 flags
= bfd_getl32 (eisd
->flags
);
547 vbn
= bfd_getl32 (eisd
->vbn
);
549 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
550 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
552 /* VMS combines psects from .obj files into isects in the .exe. This
553 process doesn't preserve enough information to reliably determine
554 what's in each section without examining the data. This is
555 especially true of DWARF debug sections. */
556 bfd_flags
= SEC_ALLOC
;
558 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
560 if (flags
& EISD__M_EXE
)
561 bfd_flags
|= SEC_CODE
;
563 if (flags
& EISD__M_NONSHRADR
)
564 bfd_flags
|= SEC_DATA
;
566 if (!(flags
& EISD__M_WRT
))
567 bfd_flags
|= SEC_READONLY
;
569 if (flags
& EISD__M_DZRO
)
570 bfd_flags
|= SEC_DATA
;
572 if (flags
& EISD__M_FIXUPVEC
)
573 bfd_flags
|= SEC_DATA
;
575 if (flags
& EISD__M_CRF
)
576 bfd_flags
|= SEC_DATA
;
578 if (flags
& EISD__M_GBL
)
580 name
= _bfd_vms_save_counted_string (eisd
->gblnam
);
581 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
582 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
584 else if (flags
& EISD__M_FIXUPVEC
)
586 else if (eisd
->type
== EISD__K_USRSTACK
)
592 name
= (char*) bfd_alloc (abfd
, 32);
593 if (flags
& EISD__M_DZRO
)
595 else if (flags
& EISD__M_EXE
)
597 else if (!(flags
& EISD__M_WRT
))
601 BFD_ASSERT (section_count
< 999);
602 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
605 section
= bfd_make_section (abfd
, name
);
610 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
611 section
->size
= size
;
612 section
->vma
= vaddr
;
614 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
621 /* Read & process EIHS record.
622 Return TRUE on success, FALSE on error. */
625 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
627 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
628 unsigned int gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
629 unsigned int gstsize ATTRIBUTE_UNUSED
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
630 unsigned int dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
631 unsigned int dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
632 unsigned int dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
633 unsigned int dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
637 vms_debug (8, "_bfd_vms_slurp_ihs\n");
638 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
639 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
644 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
646 section
= bfd_make_section (abfd
, "$DST$");
650 section
->size
= dstsize
;
651 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
653 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
656 PRIV (dst_section
) = section
;
657 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
662 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
664 section
= bfd_make_section (abfd
, "$DMT$");
668 section
->size
= dmtbytes
;
669 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
671 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
677 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
679 bfd_set_error (bfd_error_file_truncated
);
683 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
686 abfd
->flags
|= HAS_SYMS
;
692 /* Object file reading. */
694 /* Object file input functions. */
696 /* Get next record from object file to vms_buf.
697 Set PRIV(buf_size) and return it
699 This is a little tricky since it should be portable.
701 The openVMS object file has 'variable length' which means that
702 read() returns data in chunks of (hopefully) correct and expected
703 size. The linker (and other tools on VMS) depend on that. Unix
704 doesn't know about 'formatted' files, so reading and writing such
705 an object file in a Unix environment is not trivial.
707 With the tool 'file' (available on all VMS FTP sites), one
708 can view and change the attributes of a file. Changing from
709 'variable length' to 'fixed length, 512 bytes' reveals the
710 record size at the first 2 bytes of every record. The same
711 may happen during the transfer of object files from VMS to Unix,
712 at least with UCX, the DEC implementation of TCP/IP.
714 The VMS format repeats the size at bytes 2 & 3 of every record.
716 On the first call (file_format == FF_UNKNOWN) we check if
717 the first and the third byte pair (!) of the record match.
718 If they do it's an object file in an Unix environment or with
719 wrong attributes (FF_FOREIGN), else we should be in a VMS
720 environment where read() returns the record size (FF_NATIVE).
722 Reading is always done in 2 steps:
723 1. first just the record header is read and the size extracted,
724 2. then the read buffer is adjusted and the remaining bytes are
727 All file I/O is done on even file positions. */
729 #define VMS_OBJECT_ADJUSTMENT 2
732 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
734 /* Set the file format once for all on the first invocation. */
735 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
737 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
738 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
739 PRIV (recrd
.file_format
) = FF_FOREIGN
;
741 PRIV (recrd
.file_format
) = FF_NATIVE
;
744 /* The adjustment is needed only in an Unix environment. */
745 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
746 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
749 /* Implement step #1 of the object record reading procedure.
750 Return the record type or -1 on failure. */
753 _bfd_vms_get_object_record (bfd
*abfd
)
755 unsigned int test_len
= 6;
758 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
760 /* Skip alignment byte if the current position is odd. */
761 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
763 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
765 bfd_set_error (bfd_error_file_truncated
);
770 /* Read the record header */
771 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
773 bfd_set_error (bfd_error_file_truncated
);
777 /* Reset the record pointer. */
778 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
779 maybe_adjust_record_pointer_for_object (abfd
);
781 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
784 type
= bfd_getl16 (PRIV (recrd
.rec
));
786 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
787 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
792 /* Implement step #2 of the object record reading procedure.
793 Return the size of the record or 0 on failure. */
796 vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
)
798 unsigned int to_read
;
800 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
802 /* Extract record size. */
803 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
805 if (PRIV (recrd
.rec_size
) == 0)
807 bfd_set_error (bfd_error_file_truncated
);
811 /* That's what the linker manual says. */
812 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
814 bfd_set_error (bfd_error_file_truncated
);
818 /* Take into account object adjustment. */
819 to_read
= PRIV (recrd
.rec_size
);
820 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
821 to_read
+= VMS_OBJECT_ADJUSTMENT
;
823 /* Adjust the buffer. */
824 if (to_read
> PRIV (recrd
.buf_size
))
827 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
828 if (PRIV (recrd
.buf
) == NULL
)
830 PRIV (recrd
.buf_size
) = to_read
;
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
;
864 vms_rec
= PRIV (recrd
.rec
);
866 vms_debug2 ((2, "HDR/EMH\n"));
868 subtype
= bfd_getl16 (vms_rec
+ 4);
870 vms_debug2 ((3, "subtype %d\n", subtype
));
876 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
877 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
878 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
879 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
880 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20);
881 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
882 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
);
884 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
888 PRIV (hdr_data
).hdr_c_lnm
=
889 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
893 PRIV (hdr_data
).hdr_c_src
=
894 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
898 PRIV (hdr_data
).hdr_c_ttl
=
899 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
908 bfd_set_error (bfd_error_wrong_format
);
915 /* Typical sections for evax object files. */
917 #define EVAX_ABS_NAME "$ABS$"
918 #define EVAX_CODE_NAME "$CODE$"
919 #define EVAX_LINK_NAME "$LINK$"
920 #define EVAX_DATA_NAME "$DATA$"
921 #define EVAX_BSS_NAME "$BSS$"
922 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
923 #define EVAX_READONLY_NAME "$READONLY$"
924 #define EVAX_LITERAL_NAME "$LITERAL$"
925 #define EVAX_LITERALS_NAME "$LITERALS"
926 #define EVAX_COMMON_NAME "$COMMON$"
927 #define EVAX_LOCAL_NAME "$LOCAL$"
929 struct sec_flags_struct
931 const char *name
; /* Name of section. */
933 flagword flags_always
; /* Flags we set always. */
935 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
938 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
940 static const struct sec_flags_struct evax_section_flags
[] =
948 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
949 SEC_CODE
| SEC_READONLY
,
950 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
951 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
953 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
954 SEC_DATA
| SEC_READONLY
,
955 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
956 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
958 EGPS__V_REL
| EGPS__V_RD
,
959 SEC_DATA
| SEC_READONLY
,
960 EGPS__V_REL
| EGPS__V_RD
,
961 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
963 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
965 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
966 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
968 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
970 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
972 { EVAX_READONLYADDR_NAME
,
973 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
974 SEC_DATA
| SEC_READONLY
,
975 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
976 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
977 { EVAX_READONLY_NAME
,
978 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
979 SEC_DATA
| SEC_READONLY
,
980 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
981 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
983 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
985 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
986 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
987 { EVAX_LITERALS_NAME
,
988 EGPS__V_PIC
| EGPS__V_OVR
,
989 SEC_DATA
| SEC_READONLY
,
990 EGPS__V_PIC
| EGPS__V_OVR
,
991 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
993 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
995 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
996 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
999 /* Retrieve BFD section flags by name and size. */
1002 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1008 while (section_flags
[i
].name
!= NULL
)
1010 if (strcmp (name
, section_flags
[i
].name
) == 0)
1013 return section_flags
[i
].flags_hassize
;
1015 return section_flags
[i
].flags_always
;
1020 return section_flags
[i
].flags_hassize
;
1021 return section_flags
[i
].flags_always
;
1024 /* Retrieve VMS section flags by name and size. */
1027 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1033 while (section_flags
[i
].name
!= NULL
)
1035 if (strcmp (name
, section_flags
[i
].name
) == 0)
1038 return section_flags
[i
].vflags_hassize
;
1040 return section_flags
[i
].vflags_always
;
1045 return section_flags
[i
].vflags_hassize
;
1046 return section_flags
[i
].vflags_always
;
1049 /* Add SYM to the symbol table of ABFD.
1050 Return FALSE in case of error. */
1053 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1055 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1057 if (PRIV (max_sym_count
) == 0)
1059 PRIV (max_sym_count
) = 128;
1060 PRIV (syms
) = bfd_malloc
1061 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1065 PRIV (max_sym_count
) *= 2;
1066 PRIV (syms
) = bfd_realloc
1068 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1070 if (PRIV (syms
) == NULL
)
1074 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1078 /* Create a symbol whose name is ASCIC and add it to ABFD.
1079 Return NULL in case of error. */
1081 static struct vms_symbol_entry
*
1082 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1084 struct vms_symbol_entry
*entry
;
1088 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1091 entry
->namelen
= len
;
1092 memcpy (entry
->name
, ascic
, len
);
1093 entry
->name
[len
] = 0;
1094 entry
->owner
= abfd
;
1096 if (!add_symbol_entry (abfd
, entry
))
1101 /* Read and process EGSD. Return FALSE on failure. */
1104 _bfd_vms_slurp_egsd (bfd
*abfd
)
1106 int gsd_type
, gsd_size
;
1107 unsigned char *vms_rec
;
1108 unsigned long base_addr
;
1110 vms_debug2 ((2, "EGSD\n"));
1112 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1113 PRIV (recrd
.rec_size
) -= 8;
1115 /* Calculate base address for each section. */
1118 while (PRIV (recrd
.rec_size
) > 0)
1120 vms_rec
= PRIV (recrd
.rec
);
1122 gsd_type
= bfd_getl16 (vms_rec
);
1123 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1125 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1130 /* Program section definition. */
1132 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1133 flagword new_flags
, vms_flags
;
1136 vms_flags
= bfd_getl16 (egps
->flags
);
1138 if ((vms_flags
& EGPS__V_REL
) == 0)
1140 /* Use the global absolute section for all
1141 absolute sections. */
1142 section
= bfd_abs_section_ptr
;
1147 unsigned long align_addr
;
1149 name
= _bfd_vms_save_counted_string (&egps
->namlng
);
1151 section
= bfd_make_section (abfd
, name
);
1155 section
->filepos
= 0;
1156 section
->size
= bfd_getl32 (egps
->alloc
);
1157 section
->alignment_power
= egps
->align
;
1159 vms_section_data (section
)->flags
= vms_flags
;
1160 vms_section_data (section
)->no_flags
= 0;
1162 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1164 if (section
->size
> 0)
1165 new_flags
|= SEC_LOAD
;
1166 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1168 /* Set RELOC and HAS_CONTENTS if the section is not
1169 demand-zero and not empty. */
1170 new_flags
|= SEC_HAS_CONTENTS
;
1171 if (vms_flags
& EGPS__V_REL
)
1172 new_flags
|= SEC_RELOC
;
1174 if (vms_flags
& EGPS__V_EXE
)
1176 /* Set CODE if section is executable. */
1177 new_flags
|= SEC_CODE
;
1178 new_flags
&= ~SEC_DATA
;
1180 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1183 /* Give a non-overlapping vma to non absolute sections. */
1184 align_addr
= (1 << section
->alignment_power
);
1185 if ((base_addr
% align_addr
) != 0)
1186 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1187 section
->vma
= (bfd_vma
)base_addr
;
1188 base_addr
+= section
->size
;
1191 /* Append it to the section array. */
1192 if (PRIV (section_count
) >= PRIV (section_max
))
1194 if (PRIV (section_max
) == 0)
1195 PRIV (section_max
) = 16;
1197 PRIV (section_max
) *= 2;
1198 PRIV (sections
) = bfd_realloc_or_free
1199 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1200 if (PRIV (sections
) == NULL
)
1204 PRIV (sections
)[PRIV (section_count
)] = section
;
1205 PRIV (section_count
)++;
1212 struct vms_symbol_entry
*entry
;
1213 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1216 old_flags
= bfd_getl16 (egsy
->flags
);
1217 if (old_flags
& EGSY__V_DEF
)
1218 nameoff
= ESDF__B_NAMLNG
;
1220 nameoff
= ESRF__B_NAMLNG
;
1222 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1226 /* Allow only duplicate reference. */
1227 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1230 if (entry
->typ
== 0)
1232 entry
->typ
= gsd_type
;
1233 entry
->data_type
= egsy
->datyp
;
1234 entry
->flags
= old_flags
;
1237 if (old_flags
& EGSY__V_DEF
)
1239 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1241 entry
->value
= bfd_getl64 (esdf
->value
);
1242 entry
->section
= PRIV (sections
)[bfd_getl32 (esdf
->psindx
)];
1244 if (old_flags
& EGSY__V_NORM
)
1246 PRIV (norm_sym_count
)++;
1248 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1249 entry
->code_section
=
1250 PRIV (sections
)[bfd_getl32 (esdf
->ca_psindx
)];
1258 struct vms_symbol_entry
*entry
;
1259 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1262 old_flags
= bfd_getl16 (egst
->header
.flags
);
1264 entry
= add_symbol (abfd
, &egst
->namlng
);
1269 entry
->typ
= gsd_type
;
1270 entry
->data_type
= egst
->header
.datyp
;
1271 entry
->flags
= old_flags
;
1273 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1275 if (old_flags
& EGSY__V_REL
)
1276 entry
->section
= PRIV (sections
)[bfd_getl32 (egst
->psindx
)];
1278 entry
->section
= bfd_abs_section_ptr
;
1280 entry
->value
= bfd_getl64 (egst
->lp_2
);
1282 if (old_flags
& EGSY__V_NORM
)
1284 PRIV (norm_sym_count
)++;
1286 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1287 entry
->code_section
= bfd_abs_section_ptr
;
1294 /* Currently ignored. */
1299 (*_bfd_error_handler
) (_("Unknown EGSD subtype %d"), gsd_type
);
1300 bfd_set_error (bfd_error_bad_value
);
1304 PRIV (recrd
.rec_size
) -= gsd_size
;
1305 PRIV (recrd
.rec
) += gsd_size
;
1308 if (PRIV (gsd_sym_count
) > 0)
1309 abfd
->flags
|= HAS_SYMS
;
1314 /* Stack routines for vms ETIR commands. */
1316 /* Push value and section index. */
1319 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1321 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1322 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1324 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1325 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1327 if (PRIV (stackptr
) >= STACKSIZE
)
1329 bfd_set_error (bfd_error_bad_value
);
1330 (*_bfd_error_handler
) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1335 /* Pop value and section index. */
1338 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1340 if (PRIV (stackptr
) == 0)
1342 bfd_set_error (bfd_error_bad_value
);
1343 (*_bfd_error_handler
) (_("Stack underflow in _bfd_vms_pop"));
1347 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1348 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1350 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1353 /* Routines to fill sections contents during tir/etir read. */
1355 /* Initialize image buffer pointer to be filled. */
1358 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1362 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1364 sec
= PRIV (sections
)[sect
];
1368 /* Reading contents to an output bfd. */
1370 if (sec
->output_section
== NULL
)
1372 /* Section discarded. */
1373 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1375 /* This is not used. */
1376 PRIV (image_section
) = NULL
;
1377 PRIV (image_offset
) = 0;
1380 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1381 PRIV (image_section
) = sec
->output_section
;
1385 PRIV (image_offset
) = vma
;
1386 PRIV (image_section
) = sec
;
1390 /* Increment image buffer pointer by offset. */
1393 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1395 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1397 PRIV (image_offset
) += offset
;
1400 /* Save current DST location counter under specified index. */
1403 dst_define_location (bfd
*abfd
, unsigned int loc
)
1405 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1407 /* Grow the ptr offset table if necessary. */
1408 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1410 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1411 (loc
+ 1) * sizeof (unsigned int));
1412 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1415 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1418 /* Restore saved DST location counter from specified index. */
1421 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1423 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1425 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1428 /* Retrieve saved DST location counter from specified index. */
1431 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1433 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1435 return PRIV (dst_ptr_offsets
)[loc
];
1438 /* Write multiple bytes to section image. */
1441 image_write (bfd
*abfd
, unsigned char *ptr
, int size
)
1444 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1445 (long)PRIV (image_offset
));
1446 _bfd_hexdump (9, ptr
, size
, 0);
1449 if (PRIV (image_section
)->contents
!= NULL
)
1451 asection
*sec
= PRIV (image_section
);
1452 file_ptr off
= PRIV (image_offset
);
1455 if (off
> (file_ptr
)sec
->size
1456 || size
> (file_ptr
)sec
->size
1457 || off
+ size
> (file_ptr
)sec
->size
)
1459 bfd_set_error (bfd_error_bad_value
);
1463 memcpy (sec
->contents
+ off
, ptr
, size
);
1466 PRIV (image_offset
) += size
;
1470 /* Write byte to section image. */
1473 image_write_b (bfd
* abfd
, unsigned int value
)
1475 unsigned char data
[1];
1477 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1481 return image_write (abfd
, data
, sizeof (data
));
1484 /* Write 2-byte word to image. */
1487 image_write_w (bfd
* abfd
, unsigned int value
)
1489 unsigned char data
[2];
1491 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1493 bfd_putl16 (value
, data
);
1494 return image_write (abfd
, data
, sizeof (data
));
1497 /* Write 4-byte long to image. */
1500 image_write_l (bfd
* abfd
, unsigned long value
)
1502 unsigned char data
[4];
1504 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1506 bfd_putl32 (value
, data
);
1507 return image_write (abfd
, data
, sizeof (data
));
1510 /* Write 8-byte quad to image. */
1513 image_write_q (bfd
* abfd
, bfd_vma value
)
1515 unsigned char data
[8];
1517 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1519 bfd_putl64 (value
, data
);
1520 return image_write (abfd
, data
, sizeof (data
));
1524 _bfd_vms_etir_name (int cmd
)
1528 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1529 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1530 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1531 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1532 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1533 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1534 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1535 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1536 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1537 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1538 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1539 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1540 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1541 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1542 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1543 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1544 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1545 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1546 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1547 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1548 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1549 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1550 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1551 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1552 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1553 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1554 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1555 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1556 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1557 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1558 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1559 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1560 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1561 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1562 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1563 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1564 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1565 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1566 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1567 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1568 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1569 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1570 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1571 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1572 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1573 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1574 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1575 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1576 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1579 /* These names have not yet been added to this switch statement. */
1580 (*_bfd_error_handler
) (_("unknown ETIR command %d"), cmd
);
1585 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1588 _bfd_vms_get_value (bfd
*abfd
, const unsigned char *ascic
,
1589 struct bfd_link_info
*info
,
1591 struct alpha_vms_link_hash_entry
**hp
)
1596 struct alpha_vms_link_hash_entry
*h
;
1598 /* Not linking. Do not try to resolve the symbol. */
1607 for (i
= 0; i
< len
; i
++)
1608 name
[i
] = ascic
[i
+ 1];
1611 h
= (struct alpha_vms_link_hash_entry
*)
1612 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1617 && (h
->root
.type
== bfd_link_hash_defined
1618 || h
->root
.type
== bfd_link_hash_defweak
))
1619 *vma
= h
->root
.u
.def
.value
1620 + h
->root
.u
.def
.section
->output_offset
1621 + h
->root
.u
.def
.section
->output_section
->vma
;
1622 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1626 if (!(*info
->callbacks
->undefined_symbol
)
1627 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
))
1635 #define RELC_SHR_BASE 0x10000
1636 #define RELC_SEC_BASE 0x20000
1637 #define RELC_MASK 0x0ffff
1640 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1642 /* Handle undefined symbols. */
1643 if (h
== NULL
|| h
->sym
== NULL
)
1646 if (h
->sym
->typ
== EGSD__C_SYMG
)
1648 if (h
->sym
->flags
& EGSY__V_REL
)
1649 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1652 /* Can this happen (non-relocatable symg) ? I'd like to see
1657 if (h
->sym
->typ
== EGSD__C_SYM
)
1659 if (h
->sym
->flags
& EGSY__V_REL
)
1668 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1670 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1674 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1675 unsigned int rel
, bfd_vma vma
)
1677 asection
*sec
= PRIV (sections
)[rel
& RELC_MASK
];
1681 if (sec
->output_section
== NULL
)
1683 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1686 return vma
+ sec
->vma
;
1689 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1690 the output section (used during linking).
1691 Return FALSE in case of error. */
1694 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1697 unsigned int length
;
1698 unsigned char *maxptr
;
1703 struct alpha_vms_link_hash_entry
*h
;
1705 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1706 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1708 ptr
= PRIV (recrd
.rec
);
1709 length
= PRIV (recrd
.rec_size
);
1710 maxptr
= ptr
+ length
;
1712 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1714 while (ptr
< maxptr
)
1716 int cmd
= bfd_getl16 (ptr
);
1717 int cmd_length
= bfd_getl16 (ptr
+ 2);
1722 _bfd_vms_debug (4, "etir: %s(%d)\n",
1723 _bfd_vms_etir_name (cmd
), cmd
);
1724 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1732 stack 32 bit value of symbol (high bits set to 0). */
1733 case ETIR__C_STA_GBL
:
1734 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1735 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1741 stack 32 bit value, sign extend to 64 bit. */
1742 case ETIR__C_STA_LW
:
1743 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1749 stack 64 bit value of symbol. */
1750 case ETIR__C_STA_QW
:
1751 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1754 /* Stack psect base plus quadword offset
1755 arg: lw section index
1756 qw signed quadword offset (low 32 bits)
1758 Stack qw argument and section index
1759 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1760 case ETIR__C_STA_PQ
:
1764 psect
= bfd_getl32 (ptr
);
1765 if ((unsigned int) psect
>= PRIV (section_count
))
1767 (*_bfd_error_handler
) (_("bad section index in %s"),
1768 _bfd_vms_etir_name (cmd
));
1769 bfd_set_error (bfd_error_bad_value
);
1772 op1
= bfd_getl64 (ptr
+ 4);
1773 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1777 case ETIR__C_STA_LI
:
1778 case ETIR__C_STA_MOD
:
1779 case ETIR__C_STA_CKARG
:
1780 (*_bfd_error_handler
) (_("unsupported STA cmd %s"),
1781 _bfd_vms_etir_name (cmd
));
1785 /* Store byte: pop stack, write byte
1788 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1789 if (rel1
!= RELC_NONE
)
1791 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1794 /* Store word: pop stack, write word
1797 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1798 if (rel1
!= RELC_NONE
)
1800 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1803 /* Store longword: pop stack, write longword
1805 case ETIR__C_STO_LW
:
1806 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1807 if (rel1
& RELC_SEC_BASE
)
1809 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1812 else if (rel1
& RELC_SHR_BASE
)
1814 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1817 if (rel1
!= RELC_NONE
)
1819 if (rel1
!= RELC_REL
)
1821 alpha_vms_add_lw_reloc (info
);
1823 image_write_l (abfd
, op1
);
1826 /* Store quadword: pop stack, write quadword
1828 case ETIR__C_STO_QW
:
1829 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1830 if (rel1
& RELC_SEC_BASE
)
1832 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1835 else if (rel1
& RELC_SHR_BASE
)
1837 if (rel1
!= RELC_NONE
)
1839 if (rel1
!= RELC_REL
)
1841 alpha_vms_add_qw_reloc (info
);
1843 image_write_q (abfd
, op1
);
1846 /* Store immediate repeated: pop stack for repeat count
1849 case ETIR__C_STO_IMMR
:
1853 size
= bfd_getl32 (ptr
);
1854 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1855 if (rel1
!= RELC_NONE
)
1858 image_write (abfd
, ptr
+ 4, size
);
1862 /* Store global: write symbol value
1863 arg: cs global symbol name. */
1864 case ETIR__C_STO_GBL
:
1865 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1868 if (h
->sym
->typ
== EGSD__C_SYMG
)
1870 alpha_vms_add_fixup_qr
1871 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
1876 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
1878 alpha_vms_add_qw_reloc (info
);
1881 image_write_q (abfd
, op1
);
1884 /* Store code address: write address of entry point
1885 arg: cs global symbol name (procedure). */
1886 case ETIR__C_STO_CA
:
1887 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1890 if (h
->sym
->flags
& EGSY__V_NORM
)
1892 /* That's really a procedure. */
1893 if (h
->sym
->typ
== EGSD__C_SYMG
)
1895 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
1896 op1
= h
->sym
->symbol_vector
;
1900 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1901 h
->sym
->code_value
);
1902 alpha_vms_add_qw_reloc (info
);
1907 /* Symbol is not a procedure. */
1911 image_write_q (abfd
, op1
);
1914 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1916 case ETIR__C_STO_OFF
:
1917 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1919 if (!(rel1
& RELC_SEC_BASE
))
1922 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1924 image_write_q (abfd
, op1
);
1928 arg: lw count of bytes
1930 case ETIR__C_STO_IMM
:
1934 size
= bfd_getl32 (ptr
);
1935 image_write (abfd
, ptr
+ 4, size
);
1939 /* This code is 'reserved to digital' according to the openVMS
1940 linker manual, however it is generated by the DEC C compiler
1941 and defined in the include file.
1942 FIXME, since the following is just a guess
1943 store global longword: store 32bit value of symbol
1944 arg: cs symbol name. */
1945 case ETIR__C_STO_GBL_LW
:
1946 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1950 image_write_l (abfd
, op1
);
1953 case ETIR__C_STO_RB
:
1954 case ETIR__C_STO_AB
:
1955 case ETIR__C_STO_LP_PSB
:
1956 (*_bfd_error_handler
) (_("%s: not supported"),
1957 _bfd_vms_etir_name (cmd
));
1960 case ETIR__C_STO_HINT_GBL
:
1961 case ETIR__C_STO_HINT_PS
:
1962 (*_bfd_error_handler
) (_("%s: not implemented"),
1963 _bfd_vms_etir_name (cmd
));
1967 /* 200 Store-conditional Linkage Pair
1969 case ETIR__C_STC_LP
:
1971 /* 202 Store-conditional Address at global address
1975 case ETIR__C_STC_GBL
:
1977 /* 203 Store-conditional Code Address at global address
1979 cs procedure name. */
1980 case ETIR__C_STC_GCA
:
1982 /* 204 Store-conditional Address at psect + offset
1986 case ETIR__C_STC_PS
:
1987 (*_bfd_error_handler
) (_("%s: not supported"),
1988 _bfd_vms_etir_name (cmd
));
1992 /* 201 Store-conditional Linkage Pair with Procedure Signature
1998 case ETIR__C_STC_LP_PSB
:
1999 _bfd_vms_get_value (abfd
, ptr
+ 4, info
, &op1
, &h
);
2002 if (h
->sym
->typ
== EGSD__C_SYMG
)
2004 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2005 op1
= h
->sym
->symbol_vector
;
2010 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2011 h
->sym
->code_value
);
2012 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2018 /* Undefined symbol. */
2022 image_write_q (abfd
, op1
);
2023 image_write_q (abfd
, op2
);
2026 /* 205 Store-conditional NOP at address of global
2028 case ETIR__C_STC_NOP_GBL
:
2031 /* 207 Store-conditional BSR at global address
2034 case ETIR__C_STC_BSR_GBL
:
2037 /* 209 Store-conditional LDA at global address
2040 case ETIR__C_STC_LDA_GBL
:
2043 /* 211 Store-conditional BSR or Hint at global address
2046 case ETIR__C_STC_BOH_GBL
:
2047 /* Currentl ignored. */
2050 /* 213 Store-conditional NOP,BSR or HINT at global address
2053 case ETIR__C_STC_NBH_GBL
:
2055 /* 206 Store-conditional NOP at pect + offset
2058 case ETIR__C_STC_NOP_PS
:
2060 /* 208 Store-conditional BSR at pect + offset
2063 case ETIR__C_STC_BSR_PS
:
2065 /* 210 Store-conditional LDA at psect + offset
2068 case ETIR__C_STC_LDA_PS
:
2070 /* 212 Store-conditional BSR or Hint at pect + offset
2073 case ETIR__C_STC_BOH_PS
:
2075 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2077 case ETIR__C_STC_NBH_PS
:
2078 (*_bfd_error_handler
) ("%s: not supported",
2079 _bfd_vms_etir_name (cmd
));
2083 /* Det relocation base: pop stack, set image location counter
2085 case ETIR__C_CTL_SETRB
:
2086 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2087 if (!(rel1
& RELC_SEC_BASE
))
2089 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2092 /* Augment relocation base: increment image location counter by offset
2093 arg: lw offset value. */
2094 case ETIR__C_CTL_AUGRB
:
2095 op1
= bfd_getl32 (ptr
);
2096 image_inc_ptr (abfd
, op1
);
2099 /* Define location: pop index, save location counter under index
2101 case ETIR__C_CTL_DFLOC
:
2102 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2103 if (rel1
!= RELC_NONE
)
2105 dst_define_location (abfd
, op1
);
2108 /* Set location: pop index, restore location counter from index
2110 case ETIR__C_CTL_STLOC
:
2111 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2112 if (rel1
!= RELC_NONE
)
2114 dst_restore_location (abfd
, op1
);
2117 /* Stack defined location: pop index, push location counter from index
2119 case ETIR__C_CTL_STKDL
:
2120 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2121 if (rel1
!= RELC_NONE
)
2123 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2126 case ETIR__C_OPR_NOP
: /* No-op. */
2129 case ETIR__C_OPR_ADD
: /* Add. */
2130 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2131 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2132 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2134 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2136 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2139 case ETIR__C_OPR_SUB
: /* Subtract. */
2140 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2141 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2142 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2144 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2146 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2147 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2150 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2152 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2155 case ETIR__C_OPR_MUL
: /* Multiply. */
2156 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2157 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2158 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2160 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2163 case ETIR__C_OPR_DIV
: /* Divide. */
2164 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2165 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2166 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2169 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2171 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2174 case ETIR__C_OPR_AND
: /* Logical AND. */
2175 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2176 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2177 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2179 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2182 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2183 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2184 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2185 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2187 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2190 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2191 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2192 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2193 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2195 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2198 case ETIR__C_OPR_NEG
: /* Negate. */
2199 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2200 if (rel1
!= RELC_NONE
)
2202 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2205 case ETIR__C_OPR_COM
: /* Complement. */
2206 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2207 if (rel1
!= RELC_NONE
)
2209 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2212 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2213 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2214 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2215 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2218 (*_bfd_error_handler
) (_("invalid use of %s with contexts"),
2219 _bfd_vms_etir_name (cmd
));
2222 if ((int)op2
< 0) /* Shift right. */
2224 else /* Shift left. */
2226 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2229 case ETIR__C_OPR_INSV
: /* Insert field. */
2230 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2231 case ETIR__C_OPR_ROT
: /* Rotate. */
2232 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2233 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2234 (*_bfd_error_handler
) (_("%s: not supported"),
2235 _bfd_vms_etir_name (cmd
));
2239 case ETIR__C_OPR_SEL
: /* Select. */
2240 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2242 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2245 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2246 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2247 _bfd_vms_push (abfd
, op1
, rel1
);
2252 (*_bfd_error_handler
) (_("reserved cmd %d"), cmd
);
2257 ptr
+= cmd_length
- 4;
2263 /* Process EDBG/ETBT record.
2264 Return TRUE on success, FALSE on error */
2267 vms_slurp_debug (bfd
*abfd
)
2269 asection
*section
= PRIV (dst_section
);
2271 if (section
== NULL
)
2273 /* We have no way to find out beforehand how much debug info there
2274 is in an object file, so pick an initial amount and grow it as
2276 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2279 section
= bfd_make_section (abfd
, "$DST$");
2282 if (!bfd_set_section_flags (abfd
, section
, flags
))
2284 PRIV (dst_section
) = section
;
2287 PRIV (image_section
) = section
;
2288 PRIV (image_offset
) = section
->size
;
2290 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2293 section
->size
= PRIV (image_offset
);
2297 /* Process EDBG record.
2298 Return TRUE on success, FALSE on error. */
2301 _bfd_vms_slurp_edbg (bfd
*abfd
)
2303 vms_debug2 ((2, "EDBG\n"));
2305 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2307 return vms_slurp_debug (abfd
);
2310 /* Process ETBT record.
2311 Return TRUE on success, FALSE on error. */
2314 _bfd_vms_slurp_etbt (bfd
*abfd
)
2316 vms_debug2 ((2, "ETBT\n"));
2318 abfd
->flags
|= HAS_LINENO
;
2320 return vms_slurp_debug (abfd
);
2323 /* Process EEOM record.
2324 Return TRUE on success, FALSE on error. */
2327 _bfd_vms_slurp_eeom (bfd
*abfd
)
2329 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2331 vms_debug2 ((2, "EEOM\n"));
2333 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2334 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2335 if (PRIV (eom_data
).eom_w_comcod
> 1)
2337 (*_bfd_error_handler
) (_("Object module NOT error-free !\n"));
2338 bfd_set_error (bfd_error_bad_value
);
2342 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2343 if (PRIV (recrd
.rec_size
) > 10)
2345 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2346 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2347 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2348 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2350 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2355 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2358 _bfd_vms_slurp_object_records (bfd
* abfd
)
2365 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2367 type
= _bfd_vms_get_object_record (abfd
);
2370 vms_debug2 ((2, "next_record failed\n"));
2377 err
= _bfd_vms_slurp_ehdr (abfd
);
2380 err
= _bfd_vms_slurp_eeom (abfd
);
2383 err
= _bfd_vms_slurp_egsd (abfd
);
2386 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2389 err
= _bfd_vms_slurp_edbg (abfd
);
2392 err
= _bfd_vms_slurp_etbt (abfd
);
2399 vms_debug2 ((2, "slurp type %d failed\n", type
));
2403 while (type
!= EOBJ__C_EEOM
);
2408 /* Initialize private data */
2410 vms_initialize (bfd
* abfd
)
2414 amt
= sizeof (struct vms_private_data_struct
);
2415 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2416 if (abfd
->tdata
.any
== NULL
)
2419 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2421 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2422 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2423 if (PRIV (stack
) == NULL
)
2429 bfd_release (abfd
, abfd
->tdata
.any
);
2430 abfd
->tdata
.any
= NULL
;
2434 /* Check the format for a file being read.
2435 Return a (bfd_target *) if it's an object file or zero if not. */
2437 static const struct bfd_target
*
2438 alpha_vms_object_p (bfd
*abfd
)
2440 void *tdata_save
= abfd
->tdata
.any
;
2441 unsigned int test_len
;
2444 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2446 /* Allocate alpha-vms specific data. */
2447 if (!vms_initialize (abfd
))
2450 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2451 goto err_wrong_format
;
2453 /* The first challenge with VMS is to discover the kind of the file.
2455 Image files (executable or shared images) are stored as a raw
2456 stream of bytes (like on UNIX), but there is no magic number.
2458 Object files are written with RMS (record management service), ie
2459 each records are preceeded by its length (on a word - 2 bytes), and
2460 padded for word-alignment. That would be simple but when files
2461 are transfered to a UNIX filesystem (using ftp), records are lost.
2462 Only the raw content of the records are transfered. Fortunately,
2463 the Alpha Object file format also store the length of the record
2464 in the records. Is that clear ? */
2466 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2467 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2468 4 bytes minor id, 4 bytes length). */
2471 /* Size the main buffer. */
2472 buf
= (unsigned char *) bfd_malloc (test_len
);
2475 PRIV (recrd
.buf
) = buf
;
2476 PRIV (recrd
.buf_size
) = test_len
;
2478 /* Initialize the record pointer. */
2479 PRIV (recrd
.rec
) = buf
;
2481 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2483 bfd_set_error (bfd_error_file_truncated
);
2487 /* Is it an image? */
2488 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2489 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2491 unsigned int to_read
;
2492 unsigned int read_so_far
;
2493 unsigned int remaining
;
2494 unsigned int eisd_offset
, eihs_offset
;
2496 /* Extract the header size. */
2497 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2499 /* The header size is 0 for DSF files. */
2500 if (PRIV (recrd
.rec_size
) == 0)
2501 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2503 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2505 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2509 PRIV (recrd
.buf
) = NULL
;
2510 bfd_set_error (bfd_error_no_memory
);
2513 PRIV (recrd
.buf
) = buf
;
2514 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2517 /* Read the remaining record. */
2518 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2519 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2520 read_so_far
= test_len
;
2522 while (remaining
> 0)
2524 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2526 bfd_set_error (bfd_error_file_truncated
);
2527 goto err_wrong_format
;
2530 read_so_far
+= to_read
;
2531 remaining
-= to_read
;
2533 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2536 /* Reset the record pointer. */
2537 PRIV (recrd
.rec
) = buf
;
2539 vms_debug2 ((2, "file type is image\n"));
2541 if (_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
) != TRUE
)
2542 goto err_wrong_format
;
2544 if (_bfd_vms_slurp_eisd (abfd
, eisd_offset
) != TRUE
)
2545 goto err_wrong_format
;
2547 /* EIHS is optional. */
2548 if (eihs_offset
!= 0 && _bfd_vms_slurp_eihs (abfd
, eihs_offset
) != TRUE
)
2549 goto err_wrong_format
;
2555 /* Assume it's a module and adjust record pointer if necessary. */
2556 maybe_adjust_record_pointer_for_object (abfd
);
2558 /* But is it really a module? */
2559 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2560 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2562 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2563 goto err_wrong_format
;
2565 vms_debug2 ((2, "file type is module\n"));
2567 type
= bfd_getl16 (PRIV (recrd
.rec
));
2568 if (type
!= EOBJ__C_EMH
|| _bfd_vms_slurp_ehdr (abfd
) != TRUE
)
2569 goto err_wrong_format
;
2571 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
2572 goto err_wrong_format
;
2575 goto err_wrong_format
;
2578 /* Set arch_info to alpha. */
2580 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2581 goto err_wrong_format
;
2586 bfd_set_error (bfd_error_wrong_format
);
2589 if (PRIV (recrd
.buf
))
2590 free (PRIV (recrd
.buf
));
2591 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2592 bfd_release (abfd
, abfd
->tdata
.any
);
2593 abfd
->tdata
.any
= tdata_save
;
2599 /* Write an EMH/MHD record. */
2602 _bfd_vms_write_emh (bfd
*abfd
)
2604 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2606 _bfd_vms_output_alignment (recwr
, 2);
2609 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2610 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2611 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2612 _bfd_vms_output_long (recwr
, 0);
2613 _bfd_vms_output_long (recwr
, 0);
2614 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2616 /* Create module name from filename. */
2617 if (bfd_get_filename (abfd
) != 0)
2619 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2620 _bfd_vms_output_counted (recwr
, module
);
2624 _bfd_vms_output_counted (recwr
, "NONAME");
2626 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2627 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2628 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2629 _bfd_vms_output_end (abfd
, recwr
);
2632 /* Write an EMH/LMN record. */
2635 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2638 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2639 unsigned int ver
= BFD_VERSION
/ 10000;
2642 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2643 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2644 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2645 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2646 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2647 _bfd_vms_output_end (abfd
, recwr
);
2651 /* Write eom record for bfd abfd. Return FALSE on error. */
2654 _bfd_vms_write_eeom (bfd
*abfd
)
2656 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2658 vms_debug2 ((2, "vms_write_eeom\n"));
2660 _bfd_vms_output_alignment (recwr
, 2);
2662 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2663 _bfd_vms_output_long (recwr
, (unsigned long) (PRIV (vms_linkage_index
) >> 1));
2664 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2665 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2667 if ((abfd
->flags
& EXEC_P
) == 0
2668 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2672 section
= bfd_get_section_by_name (abfd
, ".link");
2675 bfd_set_error (bfd_error_nonrepresentable_section
);
2678 _bfd_vms_output_short (recwr
, 0);
2679 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2680 _bfd_vms_output_long (recwr
,
2681 (unsigned long) bfd_get_start_address (abfd
));
2682 _bfd_vms_output_long (recwr
, 0);
2685 _bfd_vms_output_end (abfd
, recwr
);
2689 /* This hash routine borrowed from GNU-EMACS, and strengthened
2693 hash_string (const char *ptr
)
2695 const unsigned char *p
= (unsigned char *) ptr
;
2696 const unsigned char *end
= p
+ strlen (ptr
);
2703 hash
= ((hash
<< 3) + (hash
<< 15) + (hash
>> 28) + c
);
2708 /* Generate a length-hashed VMS symbol name (limited to maxlen chars). */
2711 _bfd_vms_length_hash_symbol (bfd
*abfd
, const char *in
, int maxlen
)
2713 unsigned long result
;
2716 const char *old_name
;
2718 static char outbuf
[EOBJ__C_SYMSIZ
+ 1];
2722 vms_debug (4, "_bfd_vms_length_hash_symbol \"%s\"\n", in
);
2725 if (maxlen
> EOBJ__C_SYMSIZ
)
2726 maxlen
= EOBJ__C_SYMSIZ
;
2728 /* Save this for later. */
2731 /* We may need to truncate the symbol, save the hash for later. */
2732 in_len
= strlen (in
);
2734 result
= (in_len
> maxlen
) ? hash_string (in
) : 0;
2738 /* Do the length checking. */
2739 if (in_len
<= maxlen
)
2743 if (PRIV (flag_hash_long_names
))
2749 strncpy (out
, in
, (size_t) i
);
2753 if ((in_len
> maxlen
)
2754 && PRIV (flag_hash_long_names
))
2755 sprintf (out
, "_%08lx", result
);
2760 vms_debug (4, "--> [%d]\"%s\"\n", (int)strlen (outbuf
), outbuf
);
2764 && PRIV (flag_hash_long_names
)
2765 && PRIV (flag_show_after_trunc
))
2766 printf (_("Symbol %s replaced by %s\n"), old_name
, new_name
);
2772 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2774 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2777 if (vec
->max_el
== 0)
2780 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2785 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2789 /* Bump ABFD file position to next block. */
2792 alpha_vms_file_position_block (bfd
*abfd
)
2795 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2796 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2799 /* Convert from internal structure SRC to external structure DST. */
2802 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2803 struct vms_eisd
*dst
)
2805 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2806 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2807 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2808 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2810 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2811 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2812 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2813 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2814 dst
->pfc
= src
->u
.eisd
.pfc
;
2815 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2816 dst
->type
= src
->u
.eisd
.type
;
2818 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2820 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2821 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2822 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2826 /* Append EISD to the list of extra eisd for ABFD. */
2829 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2832 if (PRIV (gbl_eisd_head
) == NULL
)
2833 PRIV (gbl_eisd_head
) = eisd
;
2835 PRIV (gbl_eisd_tail
)->next
= eisd
;
2836 PRIV (gbl_eisd_tail
) = eisd
;
2839 /* Create an EISD for shared image SHRIMG.
2840 Return FALSE in case of error. */
2843 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2845 struct vms_internal_eisd_map
*eisd
;
2848 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2849 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2855 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2859 /* Fill the fields. */
2860 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2861 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2862 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2863 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2864 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2865 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2866 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2867 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2868 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2869 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2871 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2872 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2873 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2875 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2877 /* Append it to the list. */
2878 alpha_vms_append_extra_eisd (abfd
, eisd
);
2883 /* Create an EISD for section SEC.
2884 Return FALSE in case of failure. */
2887 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2889 struct vms_internal_eisd_map
*eisd
;
2891 /* Only for allocating section. */
2892 if (!(sec
->flags
& SEC_ALLOC
))
2895 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2896 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2899 vms_section_data (sec
)->eisd
= eisd
;
2901 /* Fill the fields. */
2902 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2903 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2904 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2905 eisd
->u
.eisd
.secsize
=
2906 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2907 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2908 eisd
->u
.eisd
.flags
= 0;
2909 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2910 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2911 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2912 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2914 if (sec
->flags
& SEC_CODE
)
2915 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2916 if (!(sec
->flags
& SEC_READONLY
))
2917 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2919 /* If relocations or fixup will be applied, make this isect writeable. */
2920 if (sec
->flags
& SEC_RELOC
)
2921 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2923 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
2925 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
2926 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
2928 if (sec
->flags
& SEC_LINKER_CREATED
)
2930 if (strcmp (sec
->name
, "$FIXUP$") == 0)
2931 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
2934 /* Append it to the list. */
2936 if (PRIV (eisd_head
) == NULL
)
2937 PRIV (eisd_head
) = eisd
;
2939 PRIV (eisd_tail
)->next
= eisd
;
2940 PRIV (eisd_tail
) = eisd
;
2945 /* Layout executable ABFD and write it to the disk.
2946 Return FALSE in case of failure. */
2949 alpha_vms_write_exec (bfd
*abfd
)
2951 struct vms_eihd eihd
;
2952 struct vms_eiha
*eiha
;
2953 struct vms_eihi
*eihi
;
2954 struct vms_eihs
*eihs
= NULL
;
2956 struct vms_internal_eisd_map
*first_eisd
;
2957 struct vms_internal_eisd_map
*eisd
;
2960 file_ptr gst_filepos
= 0;
2961 unsigned int lnkflags
= 0;
2963 /* Build the EIHD. */
2964 PRIV (file_pos
) = EIHD__C_LENGTH
;
2966 memset (&eihd
, 0, sizeof (eihd
));
2967 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
2969 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
2970 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
2972 bfd_putl32 (sizeof (eihd
), eihd
.size
);
2973 bfd_putl32 (0, eihd
.isdoff
);
2974 bfd_putl32 (0, eihd
.activoff
);
2975 bfd_putl32 (0, eihd
.symdbgoff
);
2976 bfd_putl32 (0, eihd
.imgidoff
);
2977 bfd_putl32 (0, eihd
.patchoff
);
2978 bfd_putl64 (0, eihd
.iafva
);
2979 bfd_putl32 (0, eihd
.version_array_off
);
2981 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
2982 bfd_putl32 (0, eihd
.subtype
);
2984 bfd_putl32 (0, eihd
.imgiocnt
);
2985 bfd_putl32 (-1, eihd
.privreqs
);
2986 bfd_putl32 (-1, eihd
.privreqs
+ 4);
2988 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2990 bfd_putl32 (0, eihd
.ident
);
2991 bfd_putl32 (0, eihd
.sysver
);
2994 bfd_putl32 (0, eihd
.symvect_size
);
2995 bfd_putl32 (16, eihd
.virt_mem_block_size
);
2996 bfd_putl32 (0, eihd
.ext_fixup_off
);
2997 bfd_putl32 (0, eihd
.noopt_psect_off
);
2998 bfd_putl32 (-1, eihd
.alias
);
3001 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
3002 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
3003 PRIV (file_pos
) += sizeof (struct vms_eiha
);
3005 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
3006 bfd_putl32 (0, eiha
->spare
);
3007 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
3008 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
3009 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
3010 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
3011 bfd_putl64 (0, eiha
->inishr
);
3014 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3015 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3016 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3018 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3019 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3024 /* Set module name. */
3025 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3026 len
= strlen (module
);
3027 if (len
> sizeof (eihi
->imgnam
) - 1)
3028 len
= sizeof (eihi
->imgnam
) - 1;
3029 eihi
->imgnam
[0] = len
;
3030 memcpy (eihi
->imgnam
+ 1, module
, len
);
3038 vms_get_time (&hi
, &lo
);
3039 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3040 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3043 eihi
->linkid
[0] = 0;
3044 eihi
->imgbid
[0] = 0;
3047 dst
= PRIV (dst_section
);
3048 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3049 if (dst
!= NULL
&& dst
->size
!= 0)
3051 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3052 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3053 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3055 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3056 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3057 bfd_putl32 (0, eihs
->dstvbn
);
3058 bfd_putl32 (0, eihs
->dstsize
);
3059 bfd_putl32 (0, eihs
->gstvbn
);
3060 bfd_putl32 (0, eihs
->gstsize
);
3061 bfd_putl32 (0, eihs
->dmtvbn
);
3062 bfd_putl32 (0, eihs
->dmtsize
);
3065 /* One EISD per section. */
3066 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3068 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3072 /* Merge section EIDS which extra ones. */
3073 if (PRIV (eisd_tail
))
3074 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3076 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3077 if (PRIV (gbl_eisd_tail
))
3078 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3080 first_eisd
= PRIV (eisd_head
);
3082 /* Add end of eisd. */
3085 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3088 eisd
->u
.eisd
.majorid
= 0;
3089 eisd
->u
.eisd
.minorid
= 0;
3090 eisd
->u
.eisd
.eisdsize
= 0;
3091 alpha_vms_append_extra_eisd (abfd
, eisd
);
3094 /* Place EISD in the file. */
3095 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3097 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3099 /* First block is a little bit special: there is a word at the end. */
3100 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3102 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3103 alpha_vms_file_position_block (abfd
);
3105 eisd
->file_pos
= PRIV (file_pos
);
3106 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3108 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3109 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3112 if (first_eisd
!= NULL
)
3114 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3115 /* Real size of end of eisd marker. */
3116 PRIV (file_pos
) += EISD__K_LENEND
;
3119 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3120 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3123 /* Place sections. */
3124 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3126 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3129 eisd
= vms_section_data (sec
)->eisd
;
3131 /* Align on a block. */
3132 alpha_vms_file_position_block (abfd
);
3133 sec
->filepos
= PRIV (file_pos
);
3136 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3138 PRIV (file_pos
) += sec
->size
;
3142 if (eihs
!= NULL
&& dst
!= NULL
)
3144 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3145 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3149 lnkflags
|= EIHD__M_DBGDMT
;
3150 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3151 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3153 if (PRIV (gsd_sym_count
) != 0)
3155 alpha_vms_file_position_block (abfd
);
3156 gst_filepos
= PRIV (file_pos
);
3157 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3158 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3162 /* Write EISD in hdr. */
3163 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3165 alpha_vms_swap_eisd_out
3166 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3168 /* Write first block. */
3169 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3170 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3173 /* Write remaining eisd. */
3176 unsigned char blk
[VMS_BLOCK_SIZE
];
3177 struct vms_internal_eisd_map
*next_eisd
;
3179 memset (blk
, 0xff, sizeof (blk
));
3180 while (eisd
!= NULL
)
3182 alpha_vms_swap_eisd_out
3184 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3186 next_eisd
= eisd
->next
;
3187 if (next_eisd
== NULL
3188 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3189 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3191 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3194 memset (blk
, 0xff, sizeof (blk
));
3200 /* Write sections. */
3201 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3203 unsigned char blk
[VMS_BLOCK_SIZE
];
3206 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3208 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3212 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3213 if (len
!= VMS_BLOCK_SIZE
)
3215 memset (blk
, 0, len
);
3216 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3222 if (gst_filepos
!= 0)
3224 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3227 _bfd_vms_write_emh (abfd
);
3228 _bfd_vms_write_lmn (abfd
, "GNU LD");
3230 /* PSC for the absolute section. */
3231 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3232 _bfd_vms_output_long (recwr
, 0);
3233 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3234 _bfd_vms_output_short (recwr
, 0);
3235 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3236 _bfd_vms_output_long (recwr
, 0);
3237 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3238 _bfd_vms_output_end_subrec (recwr
);
3239 _bfd_vms_output_end (abfd
, recwr
);
3241 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3243 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3250 _bfd_vms_output_alignment (recwr
, 8);
3251 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3252 _bfd_vms_output_long (recwr
, 0);
3254 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3255 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3256 _bfd_vms_output_short (recwr
, sym
->flags
);
3258 if (sym
->code_section
)
3259 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3262 BFD_ASSERT (sym
->code_value
== 0);
3265 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3266 _bfd_vms_output_quad
3267 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3268 _bfd_vms_output_quad (recwr
, ep
);
3269 _bfd_vms_output_quad (recwr
, val
);
3270 _bfd_vms_output_long (recwr
, 0);
3271 hash
= _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3272 _bfd_vms_output_counted (recwr
, hash
);
3273 _bfd_vms_output_end_subrec (recwr
);
3275 _bfd_vms_output_end (abfd
, recwr
);
3278 _bfd_vms_output_end (abfd
, recwr
);
3280 if (!_bfd_vms_write_eeom (abfd
))
3288 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3291 _bfd_vms_write_egsd (bfd
*abfd
)
3295 unsigned int symnum
;
3297 flagword new_flags
, old_flags
;
3298 int abs_section_index
= -1;
3299 unsigned int target_index
= 0;
3300 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3302 vms_debug2 ((2, "vms_write_egsd\n"));
3304 /* Egsd is quadword aligned. */
3305 _bfd_vms_output_alignment (recwr
, 8);
3307 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3308 _bfd_vms_output_long (recwr
, 0);
3310 /* Number sections. */
3311 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3313 if (section
->flags
& SEC_DEBUGGING
)
3315 if (!strcmp (section
->name
, ".vmsdebug"))
3317 section
->flags
|= SEC_DEBUGGING
;
3320 section
->target_index
= target_index
++;
3323 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3325 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3326 section
->target_index
, section
->name
, (int)section
->size
));
3328 /* Don't write out the VMS debug info section since it is in the
3329 ETBT and EDBG sections in etir. */
3330 if (section
->flags
& SEC_DEBUGGING
)
3333 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3334 if (_bfd_vms_output_check (recwr
, 64) < 0)
3336 _bfd_vms_output_end (abfd
, recwr
);
3337 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3338 _bfd_vms_output_long (recwr
, 0);
3341 /* Don't know if this is necessary for the linker but for now it keeps
3342 vms_slurp_gsd happy. */
3343 sname
= section
->name
;
3346 /* Remove leading dot. */
3348 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3349 sname
= EVAX_CODE_NAME
;
3350 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3351 sname
= EVAX_DATA_NAME
;
3352 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3353 sname
= EVAX_BSS_NAME
;
3354 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3355 sname
= EVAX_LINK_NAME
;
3356 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3357 sname
= EVAX_READONLY_NAME
;
3358 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3359 sname
= EVAX_LITERAL_NAME
;
3360 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3361 sname
= EVAX_LITERALS_NAME
;
3362 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3363 sname
= EVAX_COMMON_NAME
;
3364 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3365 sname
= EVAX_LOCAL_NAME
;
3368 sname
= _bfd_vms_length_hash_symbol (abfd
, sname
, EOBJ__C_SECSIZ
);
3370 if (bfd_is_com_section (section
))
3371 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3372 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3374 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3377 /* Modify them as directed. */
3378 if (section
->flags
& SEC_READONLY
)
3379 new_flags
&= ~EGPS__V_WRT
;
3381 new_flags
&= ~vms_section_data (section
)->no_flags
;
3382 new_flags
|= vms_section_data (section
)->flags
;
3384 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3385 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3386 new_flags
, (unsigned long)section
->size
));
3388 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3389 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3390 _bfd_vms_output_short (recwr
, new_flags
);
3391 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3392 _bfd_vms_output_counted (recwr
, sname
);
3393 _bfd_vms_output_end_subrec (recwr
);
3395 /* If the section is an obsolute one, remind its index as it will be
3396 used later for absolute symbols. */
3397 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3398 abs_section_index
= section
->target_index
;
3401 /* Output symbols. */
3402 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3404 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3406 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3410 symbol
= abfd
->outsymbols
[symnum
];
3411 old_flags
= symbol
->flags
;
3413 /* Work-around a missing feature: consider __main as the main entry
3415 if (*(symbol
->name
) == '_')
3417 if (strcmp (symbol
->name
, "__main") == 0)
3418 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3421 /* Only put in the GSD the global and the undefined symbols. */
3422 if (old_flags
& BSF_FILE
)
3425 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3427 /* If the LIB$INITIIALIZE section is present, add a reference to
3428 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3429 in the assembly file. */
3430 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3431 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3435 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3436 bytes for a possible ABS section. */
3437 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3439 _bfd_vms_output_end (abfd
, recwr
);
3440 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3441 _bfd_vms_output_long (recwr
, 0);
3444 if ((old_flags
& BSF_GLOBAL
) != 0
3445 && bfd_is_abs_section (symbol
->section
)
3446 && abs_section_index
<= 0)
3448 /* Create an absolute section if none was defined. It is highly
3449 unlikely that the name $ABS$ clashes with a user defined
3450 non-absolute section name. */
3451 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3452 _bfd_vms_output_short (recwr
, 4);
3453 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3454 _bfd_vms_output_long (recwr
, 0);
3455 _bfd_vms_output_counted (recwr
, "$ABS$");
3456 _bfd_vms_output_end_subrec (recwr
);
3458 abs_section_index
= target_index
++;
3461 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3463 /* Data type, alignment. */
3464 _bfd_vms_output_short (recwr
, 0);
3468 if (old_flags
& BSF_WEAK
)
3469 new_flags
|= EGSY__V_WEAK
;
3470 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3471 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3473 if (old_flags
& BSF_FUNCTION
)
3475 new_flags
|= EGSY__V_NORM
;
3476 new_flags
|= EGSY__V_REL
;
3478 if (old_flags
& BSF_GLOBAL
)
3480 new_flags
|= EGSY__V_DEF
;
3481 if (!bfd_is_abs_section (symbol
->section
))
3482 new_flags
|= EGSY__V_REL
;
3484 _bfd_vms_output_short (recwr
, new_flags
);
3486 if (old_flags
& BSF_GLOBAL
)
3488 /* Symbol definition. */
3489 bfd_vma code_address
= 0;
3490 unsigned long ca_psindx
= 0;
3491 unsigned long psindx
;
3493 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3498 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3499 code_address
= sym
->value
;
3500 ca_psindx
= sym
->section
->target_index
;
3502 if (bfd_is_abs_section (symbol
->section
))
3503 psindx
= abs_section_index
;
3505 psindx
= symbol
->section
->target_index
;
3507 _bfd_vms_output_quad (recwr
, symbol
->value
);
3508 _bfd_vms_output_quad (recwr
, code_address
);
3509 _bfd_vms_output_long (recwr
, ca_psindx
);
3510 _bfd_vms_output_long (recwr
, psindx
);
3512 hash
= _bfd_vms_length_hash_symbol (abfd
, symbol
->name
, EOBJ__C_SYMSIZ
);
3513 _bfd_vms_output_counted (recwr
, hash
);
3515 _bfd_vms_output_end_subrec (recwr
);
3518 _bfd_vms_output_alignment (recwr
, 8);
3519 _bfd_vms_output_end (abfd
, recwr
);
3524 /* Write object header for bfd abfd. Return FALSE on error. */
3527 _bfd_vms_write_ehdr (bfd
*abfd
)
3530 unsigned int symnum
;
3533 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3535 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3537 _bfd_vms_output_alignment (recwr
, 2);
3539 _bfd_vms_write_emh (abfd
);
3540 _bfd_vms_write_lmn (abfd
, "GNU AS");
3543 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3544 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3546 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3548 symbol
= abfd
->outsymbols
[symnum
];
3550 if (symbol
->flags
& BSF_FILE
)
3552 if (CONST_STRNEQ ((char *)symbol
->name
, "<CASE:"))
3554 PRIV (flag_hash_long_names
) = symbol
->name
[6] - '0';
3555 PRIV (flag_show_after_trunc
) = symbol
->name
[7] - '0';
3563 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3564 (int) strlen (symbol
->name
));
3571 if (symnum
== abfd
->symcount
)
3572 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3574 _bfd_vms_output_end (abfd
, recwr
);
3577 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3578 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3579 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3580 _bfd_vms_output_end (abfd
, recwr
);
3583 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3584 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3585 _bfd_vms_output_dump (recwr
,
3586 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3588 _bfd_vms_output_end (abfd
, recwr
);
3593 /* Part 4.6, relocations. */
3596 /* WRITE ETIR SECTION
3598 This is still under construction and therefore not documented. */
3600 /* Close the etir/etbt record. */
3603 end_etir_record (bfd
* abfd
)
3605 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3607 _bfd_vms_output_end (abfd
, recwr
);
3611 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3613 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3615 if (section
->flags
& SEC_DEBUGGING
)
3617 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3621 /* Push start offset. */
3622 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3623 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3624 _bfd_vms_output_end_subrec (recwr
);
3627 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3628 _bfd_vms_output_end_subrec (recwr
);
3633 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3637 /* Push start offset. */
3638 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3639 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3640 _bfd_vms_output_quad (recwr
, offset
);
3641 _bfd_vms_output_end_subrec (recwr
);
3643 /* Start = pop (). */
3644 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3645 _bfd_vms_output_end_subrec (recwr
);
3650 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3651 address VADDR in section specified by SEC_INDEX and NAME. */
3654 sto_imm (bfd
*abfd
, asection
*section
,
3655 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3658 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3661 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3662 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3667 /* Try all the rest. */
3670 if (_bfd_vms_output_check (recwr
, size
) < 0)
3672 /* Doesn't fit, split ! */
3673 end_etir_record (abfd
);
3675 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3677 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3678 if (size
> ssize
) /* more than what's left ? */
3682 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3683 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3684 _bfd_vms_output_dump (recwr
, cptr
, size
);
3685 _bfd_vms_output_end_subrec (recwr
);
3688 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3689 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3699 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3701 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3703 /* Not enough room in this record. Close it and open a new one. */
3704 end_etir_record (abfd
);
3705 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3709 /* Return whether RELOC must be deferred till the end. */
3712 defer_reloc_p (arelent
*reloc
)
3714 switch (reloc
->howto
->type
)
3727 /* Write section contents for bfd abfd. Return FALSE on error. */
3730 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3733 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3735 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3737 _bfd_vms_output_alignment (recwr
, 4);
3739 PRIV (vms_linkage_index
) = 1;
3741 for (section
= abfd
->sections
; section
; section
= section
->next
)
3743 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3744 section
->target_index
, section
->name
, (int) (section
->size
)));
3746 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3747 || bfd_is_com_section (section
))
3750 if (!section
->contents
)
3752 bfd_set_error (bfd_error_no_contents
);
3756 start_etir_or_etbt_record (abfd
, section
, 0);
3758 if (section
->flags
& SEC_RELOC
)
3760 bfd_vma curr_addr
= 0;
3761 unsigned char *curr_data
= section
->contents
;
3763 int pass2_needed
= 0;
3764 int pass2_in_progress
= 0;
3767 if (section
->reloc_count
== 0)
3768 (*_bfd_error_handler
)
3769 (_("SEC_RELOC with no relocs in section %s"), section
->name
);
3774 int i
= section
->reloc_count
;
3775 arelent
**rptr
= section
->orelocation
;
3776 _bfd_vms_debug (4, "%d relocations:\n", i
);
3779 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3780 "addr %08lx, off %08lx, len %d: %s\n",
3781 (*(*rptr
)->sym_ptr_ptr
)->name
,
3782 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3783 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3784 (unsigned long)(*rptr
)->address
,
3785 (unsigned long)(*rptr
)->addend
,
3786 bfd_get_reloc_size ((*rptr
)->howto
),
3787 ( *rptr
)->howto
->name
);
3794 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3796 struct evax_private_udata_struct
*udata
;
3797 arelent
*rptr
= section
->orelocation
[irel
];
3798 bfd_vma addr
= rptr
->address
;
3799 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3800 asection
*sec
= sym
->section
;
3801 bfd_boolean defer
= defer_reloc_p (rptr
);
3805 if (pass2_in_progress
)
3807 /* Non-deferred relocs have already been output. */
3813 /* Deferred relocs must be output at the very end. */
3820 /* Regular relocs are intertwined with binary data. */
3821 if (curr_addr
> addr
)
3822 (*_bfd_error_handler
) (_("Size error in section %s"),
3824 size
= addr
- curr_addr
;
3825 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3830 size
= bfd_get_reloc_size (rptr
->howto
);
3832 switch (rptr
->howto
->type
)
3834 case ALPHA_R_IGNORE
:
3837 case ALPHA_R_REFLONG
:
3838 if (bfd_is_und_section (sym
->section
))
3840 bfd_vma addend
= rptr
->addend
;
3841 slen
= strlen ((char *) sym
->name
);
3842 hash
= _bfd_vms_length_hash_symbol
3843 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3844 etir_output_check (abfd
, section
, curr_addr
, slen
);
3847 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3848 _bfd_vms_output_counted (recwr
, hash
);
3849 _bfd_vms_output_end_subrec (recwr
);
3850 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3851 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3852 _bfd_vms_output_end_subrec (recwr
);
3853 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3854 _bfd_vms_output_end_subrec (recwr
);
3855 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3856 _bfd_vms_output_end_subrec (recwr
);
3860 _bfd_vms_output_begin_subrec
3861 (recwr
, ETIR__C_STO_GBL_LW
);
3862 _bfd_vms_output_counted (recwr
, hash
);
3863 _bfd_vms_output_end_subrec (recwr
);
3866 else if (bfd_is_abs_section (sym
->section
))
3868 etir_output_check (abfd
, section
, curr_addr
, 16);
3869 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3870 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3871 _bfd_vms_output_end_subrec (recwr
);
3872 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3873 _bfd_vms_output_end_subrec (recwr
);
3877 etir_output_check (abfd
, section
, curr_addr
, 32);
3878 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3879 _bfd_vms_output_long (recwr
,
3880 (unsigned long) sec
->target_index
);
3881 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3882 _bfd_vms_output_end_subrec (recwr
);
3883 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3884 says that we should have a ETIR__C_STO_OFF here.
3885 But the relocation would not be BFD_RELOC_32 then.
3886 This case is very likely unreachable. */
3887 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3888 _bfd_vms_output_end_subrec (recwr
);
3892 case ALPHA_R_REFQUAD
:
3893 if (bfd_is_und_section (sym
->section
))
3895 bfd_vma addend
= rptr
->addend
;
3896 slen
= strlen ((char *) sym
->name
);
3897 hash
= _bfd_vms_length_hash_symbol
3898 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3899 etir_output_check (abfd
, section
, curr_addr
, slen
);
3902 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3903 _bfd_vms_output_counted (recwr
, hash
);
3904 _bfd_vms_output_end_subrec (recwr
);
3905 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3906 _bfd_vms_output_quad (recwr
, addend
);
3907 _bfd_vms_output_end_subrec (recwr
);
3908 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3909 _bfd_vms_output_end_subrec (recwr
);
3910 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3911 _bfd_vms_output_end_subrec (recwr
);
3915 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3916 _bfd_vms_output_counted (recwr
, hash
);
3917 _bfd_vms_output_end_subrec (recwr
);
3920 else if (bfd_is_abs_section (sym
->section
))
3922 etir_output_check (abfd
, section
, curr_addr
, 16);
3923 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3924 _bfd_vms_output_quad (recwr
, sym
->value
);
3925 _bfd_vms_output_end_subrec (recwr
);
3926 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3927 _bfd_vms_output_end_subrec (recwr
);
3931 etir_output_check (abfd
, section
, curr_addr
, 32);
3932 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3933 _bfd_vms_output_long (recwr
,
3934 (unsigned long) sec
->target_index
);
3935 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3936 _bfd_vms_output_end_subrec (recwr
);
3937 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3938 _bfd_vms_output_end_subrec (recwr
);
3943 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3946 case ALPHA_R_LINKAGE
:
3947 etir_output_check (abfd
, section
, curr_addr
, 64);
3948 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
3949 _bfd_vms_output_long
3950 (recwr
, (unsigned long) PRIV (vms_linkage_index
));
3951 PRIV (vms_linkage_index
) += 2;
3952 hash
= _bfd_vms_length_hash_symbol
3953 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3954 _bfd_vms_output_counted (recwr
, hash
);
3955 _bfd_vms_output_byte (recwr
, 0);
3956 _bfd_vms_output_end_subrec (recwr
);
3959 case ALPHA_R_CODEADDR
:
3960 slen
= strlen ((char *) sym
->name
);
3961 hash
= _bfd_vms_length_hash_symbol
3962 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3963 etir_output_check (abfd
, section
, curr_addr
, slen
);
3964 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
3965 _bfd_vms_output_counted (recwr
, hash
);
3966 _bfd_vms_output_end_subrec (recwr
);
3971 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3972 etir_output_check (abfd
, section
, curr_addr
,
3973 32 + 1 + strlen (udata
->origname
));
3974 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
3975 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3976 _bfd_vms_output_long
3978 (unsigned long) udata
->enbsym
->section
->target_index
);
3979 _bfd_vms_output_quad (recwr
, rptr
->address
);
3980 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
3981 _bfd_vms_output_long
3983 (unsigned long) udata
->enbsym
->section
->target_index
);
3984 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3985 _bfd_vms_output_counted
3986 (recwr
, _bfd_vms_length_hash_symbol
3987 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3988 _bfd_vms_output_end_subrec (recwr
);
3992 (*_bfd_error_handler
) (_("Spurious ALPHA_R_BSR reloc"));
3997 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3998 etir_output_check (abfd
, section
, curr_addr
,
3999 32 + 1 + strlen (udata
->origname
));
4000 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
4001 _bfd_vms_output_long
4002 (recwr
, (unsigned long) udata
->lkindex
+ 1);
4003 _bfd_vms_output_long
4005 (unsigned long) udata
->enbsym
->section
->target_index
);
4006 _bfd_vms_output_quad (recwr
, rptr
->address
);
4007 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
4008 _bfd_vms_output_long
4009 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
4010 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4011 _bfd_vms_output_counted
4012 (recwr
, _bfd_vms_length_hash_symbol
4013 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
4014 _bfd_vms_output_end_subrec (recwr
);
4019 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
4020 etir_output_check (abfd
, section
, curr_addr
,
4021 32 + 1 + strlen (udata
->origname
));
4022 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
4023 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
4024 _bfd_vms_output_long
4026 (unsigned long) udata
->enbsym
->section
->target_index
);
4027 _bfd_vms_output_quad (recwr
, rptr
->address
);
4028 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
4029 _bfd_vms_output_long
4031 (unsigned long) udata
->enbsym
->section
->target_index
);
4032 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4033 _bfd_vms_output_counted
4034 (recwr
, _bfd_vms_length_hash_symbol
4035 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
4036 _bfd_vms_output_end_subrec (recwr
);
4040 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
4047 } /* End of relocs loop. */
4049 if (!pass2_in_progress
)
4051 /* Output rest of section. */
4052 if (curr_addr
> section
->size
)
4053 (*_bfd_error_handler
) (_("Size error in section %s"),
4055 size
= section
->size
- curr_addr
;
4056 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4062 pass2_in_progress
= 1;
4068 else /* (section->flags & SEC_RELOC) */
4069 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4071 end_etir_record (abfd
);
4074 _bfd_vms_output_alignment (recwr
, 2);
4078 /* Write cached information into a file being written, at bfd_close. */
4081 alpha_vms_write_object_contents (bfd
*abfd
)
4083 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4085 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4087 return alpha_vms_write_exec (abfd
);
4091 if (abfd
->section_count
> 0) /* we have sections */
4093 if (_bfd_vms_write_ehdr (abfd
) != TRUE
)
4095 if (_bfd_vms_write_egsd (abfd
) != TRUE
)
4097 if (_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
) != TRUE
)
4099 if (_bfd_vms_write_eeom (abfd
) != TRUE
)
4106 /* Debug stuff: nearest line. */
4108 #define SET_MODULE_PARSED(m) \
4109 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4110 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4112 /* Build a new module for the specified BFD. */
4114 static struct module
*
4115 new_module (bfd
*abfd
)
4117 struct module
*module
4118 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4119 module
->file_table_count
= 16; /* Arbitrary. */
4121 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4125 /* Parse debug info for a module and internalize it. */
4128 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4131 unsigned char *maxptr
= ptr
+ length
;
4132 unsigned char *src_ptr
, *pcl_ptr
;
4133 unsigned int prev_linum
= 0, curr_linenum
= 0;
4134 bfd_vma prev_pc
= 0, curr_pc
= 0;
4135 struct srecinfo
*curr_srec
, *srec
;
4136 struct lineinfo
*curr_line
, *line
;
4137 struct funcinfo
*funcinfo
;
4139 /* Initialize tables with zero element. */
4140 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4141 module
->srec_table
= curr_srec
;
4143 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4144 module
->line_table
= curr_line
;
4146 while (length
== -1 || ptr
< maxptr
)
4148 /* The first byte is not counted in the recorded length. */
4149 int rec_length
= bfd_getl16 (ptr
) + 1;
4150 int rec_type
= bfd_getl16 (ptr
+ 2);
4152 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4154 if (length
== -1 && rec_type
== DST__K_MODEND
)
4161 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
);
4168 vms_debug2 ((3, "module: %s\n", module
->name
));
4175 funcinfo
= (struct funcinfo
*)
4176 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4178 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
);
4179 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4180 funcinfo
->next
= module
->func_table
;
4181 module
->func_table
= funcinfo
;
4183 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4184 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4188 module
->func_table
->high
= module
->func_table
->low
4189 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4191 if (module
->func_table
->high
> module
->high
)
4192 module
->high
= module
->func_table
->high
;
4194 vms_debug2 ((3, "end routine\n"));
4198 vms_debug2 ((3, "prologue\n"));
4202 vms_debug2 ((3, "epilog\n"));
4206 vms_debug2 ((3, "block\n"));
4210 vms_debug2 ((3, "end block\n"));
4214 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4216 vms_debug2 ((3, "source info\n"));
4218 while (src_ptr
< ptr
+ rec_length
)
4220 int cmd
= src_ptr
[0], cmd_length
, data
;
4224 case DST__K_SRC_DECLFILE
:
4227 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4229 = _bfd_vms_save_counted_string (src_ptr
4230 + DST_S_B_SRC_DF_FILENAME
);
4232 while (fileid
>= module
->file_table_count
)
4234 module
->file_table_count
*= 2;
4236 = bfd_realloc (module
->file_table
,
4237 module
->file_table_count
4238 * sizeof (struct fileinfo
));
4241 module
->file_table
[fileid
].name
= filename
;
4242 module
->file_table
[fileid
].srec
= 1;
4243 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4244 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4245 fileid
, module
->file_table
[fileid
].name
));
4249 case DST__K_SRC_DEFLINES_B
:
4250 /* Perform the association and set the next higher index
4252 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4253 srec
= (struct srecinfo
*)
4254 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4255 srec
->line
= curr_srec
->line
+ data
;
4256 srec
->srec
= curr_srec
->srec
+ data
;
4257 srec
->sfile
= curr_srec
->sfile
;
4258 curr_srec
->next
= srec
;
4261 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4264 case DST__K_SRC_DEFLINES_W
:
4265 /* Perform the association and set the next higher index
4267 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4268 srec
= (struct srecinfo
*)
4269 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4270 srec
->line
= curr_srec
->line
+ data
;
4271 srec
->srec
= curr_srec
->srec
+ data
,
4272 srec
->sfile
= curr_srec
->sfile
;
4273 curr_srec
->next
= srec
;
4276 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4279 case DST__K_SRC_INCRLNUM_B
:
4280 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4281 curr_srec
->line
+= data
;
4283 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4286 case DST__K_SRC_SETFILE
:
4287 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4288 curr_srec
->sfile
= data
;
4289 curr_srec
->srec
= module
->file_table
[data
].srec
;
4291 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4294 case DST__K_SRC_SETLNUM_L
:
4295 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4296 curr_srec
->line
= data
;
4298 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4301 case DST__K_SRC_SETLNUM_W
:
4302 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4303 curr_srec
->line
= data
;
4305 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4308 case DST__K_SRC_SETREC_L
:
4309 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4310 curr_srec
->srec
= data
;
4311 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4313 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4316 case DST__K_SRC_SETREC_W
:
4317 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4318 curr_srec
->srec
= data
;
4319 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4321 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4324 case DST__K_SRC_FORMFEED
:
4326 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4330 (*_bfd_error_handler
) (_("unknown source command %d"),
4336 src_ptr
+= cmd_length
;
4340 case DST__K_LINE_NUM
:
4341 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4343 vms_debug2 ((3, "line info\n"));
4345 while (pcl_ptr
< ptr
+ rec_length
)
4347 /* The command byte is signed so we must sign-extend it. */
4348 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4352 case DST__K_DELTA_PC_W
:
4353 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4357 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4360 case DST__K_DELTA_PC_L
:
4361 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4365 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4368 case DST__K_INCR_LINUM
:
4369 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4370 curr_linenum
+= data
;
4372 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4375 case DST__K_INCR_LINUM_W
:
4376 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4377 curr_linenum
+= data
;
4379 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4382 case DST__K_INCR_LINUM_L
:
4383 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4384 curr_linenum
+= data
;
4386 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4389 case DST__K_SET_LINUM_INCR
:
4390 (*_bfd_error_handler
)
4391 (_("DST__K_SET_LINUM_INCR not implemented"));
4395 case DST__K_SET_LINUM_INCR_W
:
4396 (*_bfd_error_handler
)
4397 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4401 case DST__K_RESET_LINUM_INCR
:
4402 (*_bfd_error_handler
)
4403 (_("DST__K_RESET_LINUM_INCR not implemented"));
4407 case DST__K_BEG_STMT_MODE
:
4408 (*_bfd_error_handler
)
4409 (_("DST__K_BEG_STMT_MODE not implemented"));
4413 case DST__K_END_STMT_MODE
:
4414 (*_bfd_error_handler
)
4415 (_("DST__K_END_STMT_MODE not implemented"));
4419 case DST__K_SET_LINUM_B
:
4420 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4421 curr_linenum
= data
;
4423 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4426 case DST__K_SET_LINUM
:
4427 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4428 curr_linenum
= data
;
4430 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4433 case DST__K_SET_LINUM_L
:
4434 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4435 curr_linenum
= data
;
4437 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4441 (*_bfd_error_handler
)
4442 (_("DST__K_SET_PC not implemented"));
4446 case DST__K_SET_PC_W
:
4447 (*_bfd_error_handler
)
4448 (_("DST__K_SET_PC_W not implemented"));
4452 case DST__K_SET_PC_L
:
4453 (*_bfd_error_handler
)
4454 (_("DST__K_SET_PC_L not implemented"));
4458 case DST__K_SET_STMTNUM
:
4459 (*_bfd_error_handler
)
4460 (_("DST__K_SET_STMTNUM not implemented"));
4465 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4468 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4472 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4475 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4479 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4482 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4485 case DST__K_SET_ABS_PC
:
4486 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4489 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4498 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4499 (unsigned long)curr_pc
, curr_linenum
));
4503 (*_bfd_error_handler
) (_("unknown line command %d"),
4510 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4512 || cmd
== DST__K_DELTA_PC_L
4513 || cmd
== DST__K_DELTA_PC_W
)
4515 line
= (struct lineinfo
*)
4516 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4517 line
->address
= curr_pc
;
4518 line
->line
= curr_linenum
;
4520 curr_line
->next
= line
;
4523 prev_linum
= curr_linenum
;
4525 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4526 (unsigned long)curr_pc
, curr_linenum
));
4529 pcl_ptr
+= cmd_length
;
4533 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4534 vms_debug2 ((3, "undocumented type 0x17\n"));
4538 vms_debug2 ((3, "ignoring record\n"));
4546 /* Finalize tables with EOL marker. */
4547 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4548 srec
->line
= (unsigned int) -1;
4549 srec
->srec
= (unsigned int) -1;
4550 curr_srec
->next
= srec
;
4552 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4553 line
->line
= (unsigned int) -1;
4554 line
->address
= (bfd_vma
) -1;
4555 curr_line
->next
= line
;
4557 /* Advertise that this module has been parsed. This is needed
4558 because parsing can be either performed at module creation
4559 or deferred until debug info is consumed. */
4560 SET_MODULE_PARSED (module
);
4563 /* Build the list of modules for the specified BFD. */
4565 static struct module
*
4566 build_module_list (bfd
*abfd
)
4568 struct module
*module
, *list
= NULL
;
4571 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4573 /* We have a DMT section so this must be an image. Parse the
4574 section and build the list of modules. This is sufficient
4575 since we can compute the start address and the end address
4576 of every module from the section contents. */
4577 bfd_size_type size
= bfd_get_section_size (dmt
);
4578 unsigned char *ptr
, *end
;
4580 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4584 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4587 vms_debug2 ((2, "DMT\n"));
4593 /* Each header declares a module with its start offset and size
4594 of debug info in the DST section, as well as the count of
4595 program sections (i.e. address spans) it contains. */
4596 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4597 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4598 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4599 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4601 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4602 modbeg
, msize
, count
));
4604 /* We create a 'module' structure for each program section since
4605 we only support contiguous addresses in a 'module' structure.
4606 As a consequence, the actual debug info in the DST section is
4607 shared and can be parsed multiple times; that doesn't seem to
4608 cause problems in practice. */
4611 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4612 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4613 module
= new_module (abfd
);
4614 module
->modbeg
= modbeg
;
4615 module
->size
= msize
;
4616 module
->low
= start
;
4617 module
->high
= start
+ length
;
4618 module
->next
= list
;
4620 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4622 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4629 /* We don't have a DMT section so this must be an object. Parse
4630 the module right now in order to compute its start address and
4632 void *dst
= PRIV (dst_section
)->contents
;
4637 module
= new_module (abfd
);
4638 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4645 /* Calculate and return the name of the source file and the line nearest
4646 to the wanted location in the specified module. */
4649 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4650 const char **file
, const char **func
,
4653 struct funcinfo
*funcinfo
;
4654 struct lineinfo
*lineinfo
;
4655 struct srecinfo
*srecinfo
;
4656 bfd_boolean ret
= FALSE
;
4658 /* Parse this module if that was not done at module creation. */
4659 if (! IS_MODULE_PARSED (module
))
4661 unsigned int size
= module
->size
;
4662 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4663 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4665 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4666 || bfd_bread (buffer
, size
, abfd
) != size
)
4668 bfd_set_error (bfd_error_no_debug_section
);
4672 parse_module (abfd
, module
, buffer
, size
);
4676 /* Find out the function (if any) that contains the address. */
4677 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4678 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4680 *func
= funcinfo
->name
;
4685 /* Find out the source file and the line nearest to the address. */
4686 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4687 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4689 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4690 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4692 if (srecinfo
->sfile
> 0)
4694 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4695 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4699 *file
= module
->name
;
4700 *line
= lineinfo
->line
;
4711 /* Provided a BFD, a section and an offset into the section, calculate and
4712 return the name of the source file and the line nearest to the wanted
4716 _bfd_vms_find_nearest_dst_line (bfd
*abfd
, asection
*section
,
4717 asymbol
**symbols ATTRIBUTE_UNUSED
,
4718 bfd_vma offset
, const char **file
,
4719 const char **func
, unsigned int *line
)
4721 struct module
*module
;
4723 /* What address are we looking for? */
4724 bfd_vma addr
= section
->vma
+ offset
;
4730 /* We can't do anything if there is no DST (debug symbol table). */
4731 if (PRIV (dst_section
) == NULL
)
4734 /* Create the module list - if not already done. */
4735 if (PRIV (modules
) == NULL
)
4737 PRIV (modules
) = build_module_list (abfd
);
4738 if (PRIV (modules
) == NULL
)
4742 for (module
= PRIV (modules
); module
; module
= module
->next
)
4743 if (addr
>= module
->low
&& addr
<= module
->high
)
4744 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4749 /* Canonicalizations. */
4750 /* Set name, value, section and flags of SYM from E. */
4753 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4762 flags
= BSF_NO_FLAGS
;
4768 if (e
->flags
& EGSY__V_WEAK
)
4771 if (e
->flags
& EGSY__V_DEF
)
4773 /* Symbol definition. */
4774 flags
|= BSF_GLOBAL
;
4775 if (e
->flags
& EGSY__V_NORM
)
4776 flags
|= BSF_FUNCTION
;
4782 /* Symbol reference. */
4783 sec
= bfd_und_section_ptr
;
4788 /* A universal symbol is by definition global... */
4789 flags
|= BSF_GLOBAL
;
4791 /* ...and dynamic in shared libraries. */
4792 if (abfd
->flags
& DYNAMIC
)
4793 flags
|= BSF_DYNAMIC
;
4795 if (e
->flags
& EGSY__V_WEAK
)
4798 if (!(e
->flags
& EGSY__V_DEF
))
4801 if (e
->flags
& EGSY__V_NORM
)
4802 flags
|= BSF_FUNCTION
;
4805 /* sec = e->section; */
4806 sec
= bfd_abs_section_ptr
;
4821 /* Return the number of bytes required to store a vector of pointers
4822 to asymbols for all the symbols in the BFD abfd, including a
4823 terminal NULL pointer. If there are no symbols in the BFD,
4824 then return 0. If an error occurs, return -1. */
4827 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4829 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4830 abfd
, PRIV (gsd_sym_count
)));
4832 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4835 /* Read the symbols from the BFD abfd, and fills in the vector
4836 location with pointers to the symbols and a trailing NULL.
4838 Return number of symbols read. */
4841 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4845 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4847 if (PRIV (csymbols
) == NULL
)
4849 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4850 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4852 /* Traverse table and fill symbols vector. */
4853 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4855 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4858 sym
= bfd_make_empty_symbol (abfd
);
4859 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4861 bfd_release (abfd
, PRIV (csymbols
));
4862 PRIV (csymbols
) = NULL
;
4866 PRIV (csymbols
)[i
] = sym
;
4870 if (symbols
!= NULL
)
4872 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4873 symbols
[i
] = PRIV (csymbols
)[i
];
4877 return PRIV (gsd_sym_count
);
4880 /* Read and convert relocations from ETIR. We do it once for all sections. */
4883 alpha_vms_slurp_relocs (bfd
*abfd
)
4887 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4889 /* We slurp relocs only once, for all sections. */
4890 if (PRIV (reloc_done
))
4892 PRIV (reloc_done
) = TRUE
;
4894 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4897 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4902 unsigned char *begin
;
4905 bfd_reloc_code_real_type reloc_code
;
4911 bfd_vma cur_address
;
4913 unsigned char *cur_sym
= NULL
;
4915 bfd_vma cur_addend
= 0;
4917 /* Skip non-ETIR records. */
4918 type
= _bfd_vms_get_object_record (abfd
);
4919 if (type
== EOBJ__C_EEOM
)
4921 if (type
!= EOBJ__C_ETIR
)
4924 begin
= PRIV (recrd
.rec
) + 4;
4925 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4927 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4931 cmd
= bfd_getl16 (ptr
);
4932 length
= bfd_getl16 (ptr
+ 2);
4934 cur_address
= vaddr
;
4936 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4937 _bfd_vms_etir_name (cmd
)));
4941 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4942 /* ALPHA_R_REFQUAD und_section, step 1 */
4947 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4948 cur_psidx
= bfd_getl32 (ptr
+ 4);
4949 cur_addend
= bfd_getl64 (ptr
+ 8);
4953 case ETIR__C_CTL_SETRB
:
4954 if (prev_cmd
!= ETIR__C_STA_PQ
)
4956 (*_bfd_error_handler
)
4957 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
4958 _bfd_vms_etir_name (cmd
));
4961 cur_psect
= cur_psidx
;
4967 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
4968 /* ALPHA_R_REFLONG und_section, step 2 */
4971 if (prev_cmd
!= ETIR__C_STA_GBL
)
4973 (*_bfd_error_handler
)
4974 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4975 _bfd_vms_etir_name (ETIR__C_STA_LW
));
4979 cur_addend
= bfd_getl32 (ptr
+ 4);
4983 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
4984 /* ALPHA_R_REFQUAD und_section, step 2 */
4985 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
4987 (*_bfd_error_handler
)
4988 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4989 _bfd_vms_etir_name (ETIR__C_STA_QW
));
4992 cur_addend
= bfd_getl64 (ptr
+ 4);
4996 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
4997 /* ALPHA_R_REFLONG abs_section, step 2 */
4998 /* ALPHA_R_REFLONG others, step 2 */
4999 if (prev_cmd
!= ETIR__C_OPR_ADD
5000 && prev_cmd
!= ETIR__C_STA_LW
5001 && prev_cmd
!= ETIR__C_STA_PQ
)
5003 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
5004 _bfd_vms_etir_name (prev_cmd
),
5005 _bfd_vms_etir_name (ETIR__C_STO_LW
));
5008 reloc_code
= BFD_RELOC_32
;
5011 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
5012 /* ALPHA_R_REFQUAD abs_section, step 2 */
5013 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
5015 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
5016 _bfd_vms_etir_name (prev_cmd
),
5017 _bfd_vms_etir_name (ETIR__C_STO_QW
));
5020 reloc_code
= BFD_RELOC_64
;
5023 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
5024 if (prev_cmd
!= ETIR__C_STA_PQ
)
5026 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
5027 _bfd_vms_etir_name (prev_cmd
),
5028 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
5031 reloc_code
= BFD_RELOC_64
;
5034 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
5035 /* ALPHA_R_REFQUAD und_section, step 3 */
5036 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5038 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
5039 _bfd_vms_etir_name (prev_cmd
),
5040 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5043 prev_cmd
= ETIR__C_OPR_ADD
;
5046 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5047 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5051 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5052 reloc_code
= BFD_RELOC_64
;
5056 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5057 reloc_code
= BFD_RELOC_32
;
5061 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5062 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5066 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5067 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5070 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5071 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5074 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5075 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5078 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5079 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5083 cur_sym
= ptr
+ 4 + 32;
5084 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5085 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5088 case ETIR__C_STO_IMM
:
5089 vaddr
+= bfd_getl32 (ptr
+ 4);
5093 (*_bfd_error_handler
) (_("Unknown reloc %s"),
5094 _bfd_vms_etir_name (cmd
));
5100 struct vms_section_data_struct
*vms_sec
;
5103 /* Get section to which the relocation applies. */
5104 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5106 (*_bfd_error_handler
) (_("Invalid section index in ETIR"));
5109 sec
= PRIV (sections
)[cur_psect
];
5110 vms_sec
= vms_section_data (sec
);
5112 /* Allocate a reloc entry. */
5113 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5115 if (vms_sec
->reloc_max
== 0)
5117 vms_sec
->reloc_max
= 64;
5118 sec
->relocation
= bfd_zmalloc
5119 (vms_sec
->reloc_max
* sizeof (arelent
));
5123 vms_sec
->reloc_max
*= 2;
5124 sec
->relocation
= bfd_realloc
5125 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5128 reloc
= &sec
->relocation
[sec
->reloc_count
];
5131 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5133 if (cur_sym
!= NULL
)
5136 unsigned int symlen
= *cur_sym
;
5139 /* Linear search. */
5144 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5145 if (PRIV (syms
)[j
]->namelen
== symlen
5146 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5148 sym
= &PRIV (csymbols
)[j
];
5153 (*_bfd_error_handler
) (_("Unknown symbol in command %s"),
5154 _bfd_vms_etir_name (cmd
));
5155 reloc
->sym_ptr_ptr
= NULL
;
5158 reloc
->sym_ptr_ptr
= sym
;
5160 else if (cur_psidx
>= 0)
5161 reloc
->sym_ptr_ptr
=
5162 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5164 reloc
->sym_ptr_ptr
= NULL
;
5166 reloc
->address
= cur_address
;
5167 reloc
->addend
= cur_addend
;
5169 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5178 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5183 /* Return the number of bytes required to store the relocation
5184 information associated with the given section. */
5187 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5189 alpha_vms_slurp_relocs (abfd
);
5191 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5194 /* Convert relocations from VMS (external) form into BFD internal
5195 form. Return the number of relocations. */
5198 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5199 asymbol
**symbols ATTRIBUTE_UNUSED
)
5204 if (!alpha_vms_slurp_relocs (abfd
))
5207 count
= section
->reloc_count
;
5208 tblptr
= section
->relocation
;
5211 *relptr
++ = tblptr
++;
5213 *relptr
= (arelent
*) NULL
;
5214 return section
->reloc_count
;
5217 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5219 /* How to process the various reloc types. */
5221 static bfd_reloc_status_type
5222 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5223 arelent
*reloc ATTRIBUTE_UNUSED
,
5224 asymbol
*sym ATTRIBUTE_UNUSED
,
5225 void * data ATTRIBUTE_UNUSED
,
5226 asection
*sec ATTRIBUTE_UNUSED
,
5227 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5228 char **error_message ATTRIBUTE_UNUSED
)
5231 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5232 vms_debug (2, "In section %s, symbol %s\n",
5233 sec
->name
, sym
->name
);
5234 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5235 reloc
->sym_ptr_ptr
[0]->name
,
5236 (unsigned long)reloc
->address
,
5237 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5238 vms_debug (2, "data at %p\n", data
);
5239 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5242 return bfd_reloc_ok
;
5245 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5246 from smaller values. Start with zero, widen, *then* decrement. */
5247 #define MINUS_ONE (((bfd_vma)0) - 1)
5249 static reloc_howto_type alpha_howto_table
[] =
5251 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5252 0, /* Rightshift. */
5253 0, /* Size (0 = byte, 1 = short, 2 = long). */
5255 TRUE
, /* PC relative. */
5257 complain_overflow_dont
,/* Complain_on_overflow. */
5258 reloc_nil
, /* Special_function. */
5259 "IGNORE", /* Name. */
5260 TRUE
, /* Partial_inplace. */
5261 0, /* Source mask */
5263 TRUE
), /* PC rel offset. */
5265 /* A 64 bit reference to a symbol. */
5266 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5267 0, /* Rightshift. */
5268 4, /* Size (0 = byte, 1 = short, 2 = long). */
5270 FALSE
, /* PC relative. */
5272 complain_overflow_bitfield
, /* Complain_on_overflow. */
5273 reloc_nil
, /* Special_function. */
5274 "REFQUAD", /* Name. */
5275 TRUE
, /* Partial_inplace. */
5276 MINUS_ONE
, /* Source mask. */
5277 MINUS_ONE
, /* Dest mask. */
5278 FALSE
), /* PC rel offset. */
5280 /* A 21 bit branch. The native assembler generates these for
5281 branches within the text segment, and also fills in the PC
5282 relative offset in the instruction. */
5283 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5284 2, /* Rightshift. */
5285 2, /* Size (0 = byte, 1 = short, 2 = long). */
5287 TRUE
, /* PC relative. */
5289 complain_overflow_signed
, /* Complain_on_overflow. */
5290 reloc_nil
, /* Special_function. */
5291 "BRADDR", /* Name. */
5292 TRUE
, /* Partial_inplace. */
5293 0x1fffff, /* Source mask. */
5294 0x1fffff, /* Dest mask. */
5295 FALSE
), /* PC rel offset. */
5297 /* A hint for a jump to a register. */
5298 HOWTO (ALPHA_R_HINT
, /* Type. */
5299 2, /* Rightshift. */
5300 1, /* Size (0 = byte, 1 = short, 2 = long). */
5302 TRUE
, /* PC relative. */
5304 complain_overflow_dont
,/* Complain_on_overflow. */
5305 reloc_nil
, /* Special_function. */
5307 TRUE
, /* Partial_inplace. */
5308 0x3fff, /* Source mask. */
5309 0x3fff, /* Dest mask. */
5310 FALSE
), /* PC rel offset. */
5312 /* 16 bit PC relative offset. */
5313 HOWTO (ALPHA_R_SREL16
, /* Type. */
5314 0, /* Rightshift. */
5315 1, /* Size (0 = byte, 1 = short, 2 = long). */
5317 TRUE
, /* PC relative. */
5319 complain_overflow_signed
, /* Complain_on_overflow. */
5320 reloc_nil
, /* Special_function. */
5321 "SREL16", /* Name. */
5322 TRUE
, /* Partial_inplace. */
5323 0xffff, /* Source mask. */
5324 0xffff, /* Dest mask. */
5325 FALSE
), /* PC rel offset. */
5327 /* 32 bit PC relative offset. */
5328 HOWTO (ALPHA_R_SREL32
, /* Type. */
5329 0, /* Rightshift. */
5330 2, /* Size (0 = byte, 1 = short, 2 = long). */
5332 TRUE
, /* PC relative. */
5334 complain_overflow_signed
, /* Complain_on_overflow. */
5335 reloc_nil
, /* Special_function. */
5336 "SREL32", /* Name. */
5337 TRUE
, /* Partial_inplace. */
5338 0xffffffff, /* Source mask. */
5339 0xffffffff, /* Dest mask. */
5340 FALSE
), /* PC rel offset. */
5342 /* A 64 bit PC relative offset. */
5343 HOWTO (ALPHA_R_SREL64
, /* Type. */
5344 0, /* Rightshift. */
5345 4, /* Size (0 = byte, 1 = short, 2 = long). */
5347 TRUE
, /* PC relative. */
5349 complain_overflow_signed
, /* Complain_on_overflow. */
5350 reloc_nil
, /* Special_function. */
5351 "SREL64", /* Name. */
5352 TRUE
, /* Partial_inplace. */
5353 MINUS_ONE
, /* Source mask. */
5354 MINUS_ONE
, /* Dest mask. */
5355 FALSE
), /* PC rel offset. */
5357 /* Push a value on the reloc evaluation stack. */
5358 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5359 0, /* Rightshift. */
5360 0, /* Size (0 = byte, 1 = short, 2 = long). */
5362 FALSE
, /* PC relative. */
5364 complain_overflow_dont
,/* Complain_on_overflow. */
5365 reloc_nil
, /* Special_function. */
5366 "OP_PUSH", /* Name. */
5367 FALSE
, /* Partial_inplace. */
5368 0, /* Source mask. */
5370 FALSE
), /* PC rel offset. */
5372 /* Store the value from the stack at the given address. Store it in
5373 a bitfield of size r_size starting at bit position r_offset. */
5374 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5375 0, /* Rightshift. */
5376 4, /* Size (0 = byte, 1 = short, 2 = long). */
5378 FALSE
, /* PC relative. */
5380 complain_overflow_dont
,/* Complain_on_overflow. */
5381 reloc_nil
, /* Special_function. */
5382 "OP_STORE", /* Name. */
5383 FALSE
, /* Partial_inplace. */
5384 0, /* Source mask. */
5385 MINUS_ONE
, /* Dest mask. */
5386 FALSE
), /* PC rel offset. */
5388 /* Subtract the reloc address from the value on the top of the
5389 relocation stack. */
5390 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5391 0, /* Rightshift. */
5392 0, /* Size (0 = byte, 1 = short, 2 = long). */
5394 FALSE
, /* PC relative. */
5396 complain_overflow_dont
,/* Complain_on_overflow. */
5397 reloc_nil
, /* Special_function. */
5398 "OP_PSUB", /* Name. */
5399 FALSE
, /* Partial_inplace. */
5400 0, /* Source mask. */
5402 FALSE
), /* PC rel offset. */
5404 /* Shift the value on the top of the relocation stack right by the
5406 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5407 0, /* Rightshift. */
5408 0, /* Size (0 = byte, 1 = short, 2 = long). */
5410 FALSE
, /* PC relative. */
5412 complain_overflow_dont
,/* Complain_on_overflow. */
5413 reloc_nil
, /* Special_function. */
5414 "OP_PRSHIFT", /* Name. */
5415 FALSE
, /* Partial_inplace. */
5416 0, /* Source mask. */
5418 FALSE
), /* PC rel offset. */
5420 /* Hack. Linkage is done by linker. */
5421 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5422 0, /* Rightshift. */
5423 8, /* Size (0 = byte, 1 = short, 2 = long). */
5425 FALSE
, /* PC relative. */
5427 complain_overflow_dont
,/* Complain_on_overflow. */
5428 reloc_nil
, /* Special_function. */
5429 "LINKAGE", /* Name. */
5430 FALSE
, /* Partial_inplace. */
5431 0, /* Source mask. */
5433 FALSE
), /* PC rel offset. */
5435 /* A 32 bit reference to a symbol. */
5436 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5437 0, /* Rightshift. */
5438 2, /* Size (0 = byte, 1 = short, 2 = long). */
5440 FALSE
, /* PC relative. */
5442 complain_overflow_bitfield
, /* Complain_on_overflow. */
5443 reloc_nil
, /* Special_function. */
5444 "REFLONG", /* Name. */
5445 TRUE
, /* Partial_inplace. */
5446 0xffffffff, /* Source mask. */
5447 0xffffffff, /* Dest mask. */
5448 FALSE
), /* PC rel offset. */
5450 /* A 64 bit reference to a procedure, written as 32 bit value. */
5451 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5452 0, /* Rightshift. */
5453 4, /* Size (0 = byte, 1 = short, 2 = long). */
5455 FALSE
, /* PC relative. */
5457 complain_overflow_signed
,/* Complain_on_overflow. */
5458 reloc_nil
, /* Special_function. */
5459 "CODEADDR", /* Name. */
5460 FALSE
, /* Partial_inplace. */
5461 0xffffffff, /* Source mask. */
5462 0xffffffff, /* Dest mask. */
5463 FALSE
), /* PC rel offset. */
5465 HOWTO (ALPHA_R_NOP
, /* Type. */
5466 0, /* Rightshift. */
5467 3, /* Size (0 = byte, 1 = short, 2 = long). */
5469 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5470 because the calculations for the 3 relocations are the same.
5471 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5472 TRUE
, /* PC relative. */
5474 complain_overflow_dont
,/* Complain_on_overflow. */
5475 reloc_nil
, /* Special_function. */
5477 FALSE
, /* Partial_inplace. */
5478 0xffffffff, /* Source mask. */
5479 0xffffffff, /* Dest mask. */
5480 FALSE
), /* PC rel offset. */
5482 HOWTO (ALPHA_R_BSR
, /* Type. */
5483 0, /* Rightshift. */
5484 3, /* Size (0 = byte, 1 = short, 2 = long). */
5486 TRUE
, /* PC relative. */
5488 complain_overflow_dont
,/* Complain_on_overflow. */
5489 reloc_nil
, /* Special_function. */
5491 FALSE
, /* Partial_inplace. */
5492 0xffffffff, /* Source mask. */
5493 0xffffffff, /* Dest mask. */
5494 FALSE
), /* PC rel offset. */
5496 HOWTO (ALPHA_R_LDA
, /* Type. */
5497 0, /* Rightshift. */
5498 3, /* Size (0 = byte, 1 = short, 2 = long). */
5500 FALSE
, /* PC relative. */
5502 complain_overflow_dont
,/* Complain_on_overflow. */
5503 reloc_nil
, /* Special_function. */
5505 FALSE
, /* Partial_inplace. */
5506 0xffffffff, /* Source mask. */
5507 0xffffffff, /* Dest mask. */
5508 FALSE
), /* PC rel offset. */
5510 HOWTO (ALPHA_R_BOH
, /* Type. */
5511 0, /* Rightshift. */
5512 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5514 TRUE
, /* PC relative. */
5516 complain_overflow_dont
,/* Complain_on_overflow. */
5517 reloc_nil
, /* Special_function. */
5519 FALSE
, /* Partial_inplace. */
5520 0xffffffff, /* Source mask. */
5521 0xffffffff, /* Dest mask. */
5522 FALSE
), /* PC rel offset. */
5525 /* Return a pointer to a howto structure which, when invoked, will perform
5526 the relocation code on data from the architecture noted. */
5528 static const struct reloc_howto_struct
*
5529 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5530 bfd_reloc_code_real_type code
)
5534 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5538 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5539 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5540 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5541 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5542 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5543 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5544 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5545 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5546 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5547 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5548 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5549 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5550 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5551 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5552 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5554 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
5557 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5558 return & alpha_howto_table
[alpha_type
];
5561 static reloc_howto_type
*
5562 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5568 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5570 if (alpha_howto_table
[i
].name
!= NULL
5571 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5572 return &alpha_howto_table
[i
];
5578 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5579 long symcount ATTRIBUTE_UNUSED
,
5580 asymbol
**usyms ATTRIBUTE_UNUSED
,
5581 long dynsymcount ATTRIBUTE_UNUSED
,
5582 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5589 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5594 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5596 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5607 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5614 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5616 value
= e
->code_value
;
5617 sec
= e
->code_section
;
5628 sname
= bfd_alloc (abfd
, l
+ 5);
5631 memcpy (sname
, name
, l
);
5632 memcpy (sname
+ l
, "..en", 5);
5639 sym
->udata
.p
= NULL
;
5648 vms_time_to_str (unsigned char *buf
)
5650 time_t t
= vms_rawtime_to_time_t (buf
);
5651 char *res
= ctime (&t
);
5654 res
= "*invalid time*";
5661 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5663 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5664 unsigned int subtype
;
5666 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5668 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5674 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5677 fprintf (file
, _("Module header\n"));
5678 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5679 fprintf (file
, _(" max record size: %u\n"),
5680 (unsigned)bfd_getl32 (mhd
->recsiz
));
5681 name
= (char *)(mhd
+ 1);
5682 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5683 name
+= name
[0] + 1;
5684 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5685 name
+= name
[0] + 1;
5686 fprintf (file
, _(" compile date : %.17s\n"), name
);
5691 fprintf (file
, _("Language Processor Name\n"));
5692 fprintf (file
, _(" language name: %.*s\n"),
5693 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5694 (char *)rec
+ sizeof (struct vms_emh_common
));
5699 fprintf (file
, _("Source Files Header\n"));
5700 fprintf (file
, _(" file: %.*s\n"),
5701 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5702 (char *)rec
+ sizeof (struct vms_emh_common
));
5707 fprintf (file
, _("Title Text Header\n"));
5708 fprintf (file
, _(" title: %.*s\n"),
5709 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5710 (char *)rec
+ sizeof (struct vms_emh_common
));
5715 fprintf (file
, _("Copyright Header\n"));
5716 fprintf (file
, _(" copyright: %.*s\n"),
5717 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5718 (char *)rec
+ sizeof (struct vms_emh_common
));
5722 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5728 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5730 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5732 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5733 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5734 (unsigned)bfd_getl32 (eeom
->total_lps
));
5735 fprintf (file
, _(" completion code: %u\n"),
5736 (unsigned)bfd_getl16 (eeom
->comcod
));
5739 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5740 fprintf (file
, _(" transfer addr psect: %u\n"),
5741 (unsigned)bfd_getl32 (eeom
->psindx
));
5742 fprintf (file
, _(" transfer address : 0x%08x\n"),
5743 (unsigned)bfd_getl32 (eeom
->tfradr
));
5748 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5750 if (flags
& EGSY__V_WEAK
)
5751 fputs (_(" WEAK"), file
);
5752 if (flags
& EGSY__V_DEF
)
5753 fputs (_(" DEF"), file
);
5754 if (flags
& EGSY__V_UNI
)
5755 fputs (_(" UNI"), file
);
5756 if (flags
& EGSY__V_REL
)
5757 fputs (_(" REL"), file
);
5758 if (flags
& EGSY__V_COMM
)
5759 fputs (_(" COMM"), file
);
5760 if (flags
& EGSY__V_VECEP
)
5761 fputs (_(" VECEP"), file
);
5762 if (flags
& EGSY__V_NORM
)
5763 fputs (_(" NORM"), file
);
5764 if (flags
& EGSY__V_QUAD_VAL
)
5765 fputs (_(" QVAL"), file
);
5769 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5771 if (flags
& EGPS__V_PIC
)
5772 fputs (_(" PIC"), file
);
5773 if (flags
& EGPS__V_LIB
)
5774 fputs (_(" LIB"), file
);
5775 if (flags
& EGPS__V_OVR
)
5776 fputs (_(" OVR"), file
);
5777 if (flags
& EGPS__V_REL
)
5778 fputs (_(" REL"), file
);
5779 if (flags
& EGPS__V_GBL
)
5780 fputs (_(" GBL"), file
);
5781 if (flags
& EGPS__V_SHR
)
5782 fputs (_(" SHR"), file
);
5783 if (flags
& EGPS__V_EXE
)
5784 fputs (_(" EXE"), file
);
5785 if (flags
& EGPS__V_RD
)
5786 fputs (_(" RD"), file
);
5787 if (flags
& EGPS__V_WRT
)
5788 fputs (_(" WRT"), file
);
5789 if (flags
& EGPS__V_VEC
)
5790 fputs (_(" VEC"), file
);
5791 if (flags
& EGPS__V_NOMOD
)
5792 fputs (_(" NOMOD"), file
);
5793 if (flags
& EGPS__V_COM
)
5794 fputs (_(" COM"), file
);
5795 if (flags
& EGPS__V_ALLOC_64BIT
)
5796 fputs (_(" 64B"), file
);
5800 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5802 unsigned int off
= sizeof (struct vms_egsd
);
5805 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5808 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5810 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5814 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5815 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5817 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5825 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5826 unsigned int flags
= bfd_getl16 (egps
->flags
);
5829 fprintf (file
, _("PSC - Program section definition\n"));
5830 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5831 fprintf (file
, _(" flags : 0x%04x"), flags
);
5832 evax_bfd_print_egsd_flags (file
, flags
);
5834 l
= bfd_getl32 (egps
->alloc
);
5835 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5836 fprintf (file
, _(" name : %.*s\n"),
5837 egps
->namlng
, egps
->name
);
5842 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5843 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5846 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5847 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5848 fprintf (file
, _(" flags : 0x%04x"), flags
);
5849 evax_bfd_print_egsd_flags (file
, flags
);
5851 l
= bfd_getl32 (esgps
->alloc
);
5852 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5853 fprintf (file
, _(" image offset : 0x%08x\n"),
5854 (unsigned int)bfd_getl32 (esgps
->base
));
5855 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5856 (unsigned int)bfd_getl32 (esgps
->value
));
5857 fprintf (file
, _(" name : %.*s\n"),
5858 esgps
->namlng
, esgps
->name
);
5863 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5864 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5866 if (flags
& EGSY__V_DEF
)
5868 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5870 fprintf (file
, _("SYM - Global symbol definition\n"));
5871 fprintf (file
, _(" flags: 0x%04x"), flags
);
5872 exav_bfd_print_egsy_flags (flags
, file
);
5874 fprintf (file
, _(" psect offset: 0x%08x\n"),
5875 (unsigned)bfd_getl32 (esdf
->value
));
5876 if (flags
& EGSY__V_NORM
)
5878 fprintf (file
, _(" code address: 0x%08x\n"),
5879 (unsigned)bfd_getl32 (esdf
->code_address
));
5880 fprintf (file
, _(" psect index for entry point : %u\n"),
5881 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5883 fprintf (file
, _(" psect index : %u\n"),
5884 (unsigned)bfd_getl32 (esdf
->psindx
));
5885 fprintf (file
, _(" name : %.*s\n"),
5886 esdf
->namlng
, esdf
->name
);
5890 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5892 fprintf (file
, _("SYM - Global symbol reference\n"));
5893 fprintf (file
, _(" name : %.*s\n"),
5894 esrf
->namlng
, esrf
->name
);
5900 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
5901 unsigned int flags
= bfd_getl32 (eidc
->flags
);
5904 fprintf (file
, _("IDC - Ident Consistency check\n"));
5905 fprintf (file
, _(" flags : 0x%08x"), flags
);
5906 if (flags
& EIDC__V_BINIDENT
)
5907 fputs (" BINDENT", file
);
5909 fprintf (file
, _(" id match : %x\n"),
5910 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
5911 fprintf (file
, _(" error severity: %x\n"),
5912 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
5914 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
5916 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
5918 if (flags
& EIDC__V_BINIDENT
)
5919 fprintf (file
, _(" binary ident : 0x%08x\n"),
5920 (unsigned)bfd_getl32 (p
+ 1));
5922 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
5927 struct vms_egst
*egst
= (struct vms_egst
*)e
;
5928 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
5930 fprintf (file
, _("SYMG - Universal symbol definition\n"));
5931 fprintf (file
, _(" flags: 0x%04x"), flags
);
5932 exav_bfd_print_egsy_flags (flags
, file
);
5934 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
5935 (unsigned)bfd_getl32 (egst
->value
));
5936 fprintf (file
, _(" entry point: 0x%08x\n"),
5937 (unsigned)bfd_getl32 (egst
->lp_1
));
5938 fprintf (file
, _(" proc descr : 0x%08x\n"),
5939 (unsigned)bfd_getl32 (egst
->lp_2
));
5940 fprintf (file
, _(" psect index: %u\n"),
5941 (unsigned)bfd_getl32 (egst
->psindx
));
5942 fprintf (file
, _(" name : %.*s\n"),
5943 egst
->namlng
, egst
->name
);
5948 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
5949 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
5951 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
5952 fprintf (file
, _(" flags: 0x%04x"), flags
);
5953 exav_bfd_print_egsy_flags (flags
, file
);
5955 fprintf (file
, _(" vector : 0x%08x\n"),
5956 (unsigned)bfd_getl32 (esdfv
->vector
));
5957 fprintf (file
, _(" psect offset: %u\n"),
5958 (unsigned)bfd_getl32 (esdfv
->value
));
5959 fprintf (file
, _(" psect index : %u\n"),
5960 (unsigned)bfd_getl32 (esdfv
->psindx
));
5961 fprintf (file
, _(" name : %.*s\n"),
5962 esdfv
->namlng
, esdfv
->name
);
5967 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
5968 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
5970 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
5971 fprintf (file
, _(" flags: 0x%04x"), flags
);
5972 exav_bfd_print_egsy_flags (flags
, file
);
5974 fprintf (file
, _(" version mask: 0x%08x\n"),
5975 (unsigned)bfd_getl32 (esdfm
->version_mask
));
5976 fprintf (file
, _(" psect offset: %u\n"),
5977 (unsigned)bfd_getl32 (esdfm
->value
));
5978 fprintf (file
, _(" psect index : %u\n"),
5979 (unsigned)bfd_getl32 (esdfm
->psindx
));
5980 fprintf (file
, _(" name : %.*s\n"),
5981 esdfm
->namlng
, esdfm
->name
);
5985 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
5993 evax_bfd_print_hex (FILE *file
, const char *pfx
,
5994 const unsigned char *buf
, unsigned int len
)
6000 for (i
= 0; i
< len
; i
++)
6004 fprintf (file
, " %02x", buf
[i
]);
6017 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
6019 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
6020 (unsigned)bfd_getl32 (buf
),
6021 (unsigned)bfd_getl32 (buf
+ 16));
6022 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
6023 (unsigned)bfd_getl32 (buf
+ 4),
6024 (unsigned)bfd_getl32 (buf
+ 12),
6025 (unsigned)bfd_getl32 (buf
+ 8));
6026 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
6027 (unsigned)bfd_getl32 (buf
+ 20),
6028 (unsigned)bfd_getl32 (buf
+ 28),
6029 (unsigned)bfd_getl32 (buf
+ 24));
6031 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
6032 (unsigned)bfd_getl32 (buf
+ 32),
6033 (unsigned)bfd_getl32 (buf
+ 40),
6034 (unsigned)bfd_getl32 (buf
+ 36));
6036 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6040 evax_bfd_print_etir (FILE *file
, const char *name
,
6041 unsigned char *rec
, unsigned int rec_len
)
6043 unsigned int off
= sizeof (struct vms_egsd
);
6044 unsigned int sec_len
;
6046 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6047 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6048 (unsigned)sizeof (struct vms_eobjrec
));
6050 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6052 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6057 type
= bfd_getl16 (etir
->rectyp
);
6058 size
= bfd_getl16 (etir
->size
);
6059 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6061 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6064 case ETIR__C_STA_GBL
:
6065 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6068 case ETIR__C_STA_LW
:
6069 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6070 (unsigned)bfd_getl32 (buf
));
6072 case ETIR__C_STA_QW
:
6073 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6074 (unsigned)bfd_getl32 (buf
+ 4),
6075 (unsigned)bfd_getl32 (buf
+ 0));
6077 case ETIR__C_STA_PQ
:
6078 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6079 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6080 (unsigned)bfd_getl32 (buf
+ 0),
6081 (unsigned)bfd_getl32 (buf
+ 8),
6082 (unsigned)bfd_getl32 (buf
+ 4));
6084 case ETIR__C_STA_LI
:
6085 fprintf (file
, _("STA_LI (stack literal)\n"));
6087 case ETIR__C_STA_MOD
:
6088 fprintf (file
, _("STA_MOD (stack module)\n"));
6090 case ETIR__C_STA_CKARG
:
6091 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6095 fprintf (file
, _("STO_B (store byte)\n"));
6098 fprintf (file
, _("STO_W (store word)\n"));
6100 case ETIR__C_STO_LW
:
6101 fprintf (file
, _("STO_LW (store longword)\n"));
6103 case ETIR__C_STO_QW
:
6104 fprintf (file
, _("STO_QW (store quadword)\n"));
6106 case ETIR__C_STO_IMMR
:
6108 unsigned int len
= bfd_getl32 (buf
);
6110 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6112 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6116 case ETIR__C_STO_GBL
:
6117 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6120 case ETIR__C_STO_CA
:
6121 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6124 case ETIR__C_STO_RB
:
6125 fprintf (file
, _("STO_RB (store relative branch)\n"));
6127 case ETIR__C_STO_AB
:
6128 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6130 case ETIR__C_STO_OFF
:
6131 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6133 case ETIR__C_STO_IMM
:
6135 unsigned int len
= bfd_getl32 (buf
);
6137 _("STO_IMM (store immediate) %u bytes\n"),
6139 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6143 case ETIR__C_STO_GBL_LW
:
6144 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6147 case ETIR__C_STO_LP_PSB
:
6148 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6150 case ETIR__C_STO_HINT_GBL
:
6151 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6153 case ETIR__C_STO_HINT_PS
:
6154 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6157 case ETIR__C_OPR_NOP
:
6158 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6160 case ETIR__C_OPR_ADD
:
6161 fprintf (file
, _("OPR_ADD (add)\n"));
6163 case ETIR__C_OPR_SUB
:
6164 fprintf (file
, _("OPR_SUB (substract)\n"));
6166 case ETIR__C_OPR_MUL
:
6167 fprintf (file
, _("OPR_MUL (multiply)\n"));
6169 case ETIR__C_OPR_DIV
:
6170 fprintf (file
, _("OPR_DIV (divide)\n"));
6172 case ETIR__C_OPR_AND
:
6173 fprintf (file
, _("OPR_AND (logical and)\n"));
6175 case ETIR__C_OPR_IOR
:
6176 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6178 case ETIR__C_OPR_EOR
:
6179 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6181 case ETIR__C_OPR_NEG
:
6182 fprintf (file
, _("OPR_NEG (negate)\n"));
6184 case ETIR__C_OPR_COM
:
6185 fprintf (file
, _("OPR_COM (complement)\n"));
6187 case ETIR__C_OPR_INSV
:
6188 fprintf (file
, _("OPR_INSV (insert field)\n"));
6190 case ETIR__C_OPR_ASH
:
6191 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6193 case ETIR__C_OPR_USH
:
6194 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6196 case ETIR__C_OPR_ROT
:
6197 fprintf (file
, _("OPR_ROT (rotate)\n"));
6199 case ETIR__C_OPR_SEL
:
6200 fprintf (file
, _("OPR_SEL (select)\n"));
6202 case ETIR__C_OPR_REDEF
:
6203 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6205 case ETIR__C_OPR_DFLIT
:
6206 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6209 case ETIR__C_STC_LP
:
6210 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6212 case ETIR__C_STC_LP_PSB
:
6214 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6215 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6216 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6217 buf
+= 4 + 1 + buf
[4];
6218 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6220 case ETIR__C_STC_GBL
:
6221 fprintf (file
, _("STC_GBL (store cond global)\n"));
6222 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6223 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6225 case ETIR__C_STC_GCA
:
6226 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6227 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6228 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6230 case ETIR__C_STC_PS
:
6231 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6233 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6234 (unsigned)bfd_getl32 (buf
),
6235 (unsigned)bfd_getl32 (buf
+ 4),
6236 (unsigned)bfd_getl32 (buf
+ 12),
6237 (unsigned)bfd_getl32 (buf
+ 8));
6239 case ETIR__C_STC_NOP_GBL
:
6240 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6241 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6243 case ETIR__C_STC_NOP_PS
:
6244 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6245 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6247 case ETIR__C_STC_BSR_GBL
:
6248 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6249 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6251 case ETIR__C_STC_BSR_PS
:
6252 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6253 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6255 case ETIR__C_STC_LDA_GBL
:
6256 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6257 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6259 case ETIR__C_STC_LDA_PS
:
6260 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6261 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6263 case ETIR__C_STC_BOH_GBL
:
6264 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6265 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6267 case ETIR__C_STC_BOH_PS
:
6268 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6269 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6271 case ETIR__C_STC_NBH_GBL
:
6273 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6275 case ETIR__C_STC_NBH_PS
:
6277 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6280 case ETIR__C_CTL_SETRB
:
6281 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6284 case ETIR__C_CTL_AUGRB
:
6286 unsigned int val
= bfd_getl32 (buf
);
6287 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6290 case ETIR__C_CTL_DFLOC
:
6291 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6293 case ETIR__C_CTL_STLOC
:
6294 fprintf (file
, _("CTL_STLOC (set location)\n"));
6296 case ETIR__C_CTL_STKDL
:
6297 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6300 fprintf (file
, _("*unhandled*\n"));
6308 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6310 bfd_boolean is_first
= TRUE
;
6311 bfd_boolean has_records
= FALSE
;
6315 unsigned int rec_len
;
6316 unsigned int pad_len
;
6318 unsigned int hdr_size
;
6323 unsigned char buf
[6];
6328 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6330 fprintf (file
, _("cannot read GST record length\n"));
6333 rec_len
= bfd_getl16 (buf
+ 0);
6334 if (rec_len
== bfd_getl16 (buf
+ 4)
6335 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6337 /* The format is raw: record-size, type, record-size. */
6339 pad_len
= (rec_len
+ 1) & ~1U;
6342 else if (rec_len
== EOBJ__C_EMH
)
6344 has_records
= FALSE
;
6345 pad_len
= bfd_getl16 (buf
+ 2);
6351 fprintf (file
, _("cannot find EMH in first GST record\n"));
6354 rec
= bfd_malloc (pad_len
);
6355 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6359 unsigned int rec_len2
= 0;
6360 unsigned char hdr
[4];
6364 unsigned char buf_len
[2];
6366 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6367 != sizeof (buf_len
))
6369 fprintf (file
, _("cannot read GST record length\n"));
6372 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6375 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6377 fprintf (file
, _("cannot read GST record header\n"));
6380 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6382 pad_len
= (rec_len
+ 1) & ~1U;
6385 rec
= bfd_malloc (pad_len
);
6386 memcpy (rec
, hdr
, sizeof (hdr
));
6387 hdr_size
= sizeof (hdr
);
6388 if (has_records
&& rec_len2
!= rec_len
)
6390 fprintf (file
, _(" corrupted GST\n"));
6395 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6396 != pad_len
- hdr_size
)
6398 fprintf (file
, _("cannot read GST record\n"));
6402 type
= (unsigned)bfd_getl16 (rec
);
6407 evax_bfd_print_emh (file
, rec
, rec_len
);
6410 evax_bfd_print_egsd (file
, rec
, rec_len
);
6413 evax_bfd_print_eeom (file
, rec
, rec_len
);
6418 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6421 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6424 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6427 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6435 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6436 unsigned int stride
)
6444 count
= bfd_getl32 (rel
+ 0);
6448 base
= bfd_getl32 (rel
+ 4);
6450 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6454 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6460 val
= bfd_getl32 (rel
);
6463 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6465 for (k
= 0; k
< 32; k
++)
6470 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6485 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6492 count
= bfd_getl32 (rel
+ 0);
6495 fprintf (file
, _(" image %u (%u entries)\n"),
6496 (unsigned)bfd_getl32 (rel
+ 4), count
);
6498 for (j
= 0; j
< count
; j
++)
6500 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6501 (unsigned)bfd_getl32 (rel
+ 0),
6502 (unsigned)bfd_getl32 (rel
+ 4));
6509 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6518 count
= bfd_getl32 (rel
+ 0);
6521 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6522 (unsigned)bfd_getl32 (rel
+ 4), count
);
6524 for (j
= 0; j
< count
; j
++)
6528 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6543 evax_bfd_print_indent (int indent
, FILE *file
)
6545 for (; indent
; indent
--)
6550 evax_bfd_get_dsc_name (unsigned int v
)
6554 case DSC__K_DTYPE_Z
:
6555 return "Z (Unspecified)";
6556 case DSC__K_DTYPE_V
:
6558 case DSC__K_DTYPE_BU
:
6559 return "BU (Byte logical)";
6560 case DSC__K_DTYPE_WU
:
6561 return "WU (Word logical)";
6562 case DSC__K_DTYPE_LU
:
6563 return "LU (Longword logical)";
6564 case DSC__K_DTYPE_QU
:
6565 return "QU (Quadword logical)";
6566 case DSC__K_DTYPE_B
:
6567 return "B (Byte integer)";
6568 case DSC__K_DTYPE_W
:
6569 return "W (Word integer)";
6570 case DSC__K_DTYPE_L
:
6571 return "L (Longword integer)";
6572 case DSC__K_DTYPE_Q
:
6573 return "Q (Quadword integer)";
6574 case DSC__K_DTYPE_F
:
6575 return "F (Single-precision floating)";
6576 case DSC__K_DTYPE_D
:
6577 return "D (Double-precision floating)";
6578 case DSC__K_DTYPE_FC
:
6579 return "FC (Complex)";
6580 case DSC__K_DTYPE_DC
:
6581 return "DC (Double-precision Complex)";
6582 case DSC__K_DTYPE_T
:
6583 return "T (ASCII text string)";
6584 case DSC__K_DTYPE_NU
:
6585 return "NU (Numeric string, unsigned)";
6586 case DSC__K_DTYPE_NL
:
6587 return "NL (Numeric string, left separate sign)";
6588 case DSC__K_DTYPE_NLO
:
6589 return "NLO (Numeric string, left overpunched sign)";
6590 case DSC__K_DTYPE_NR
:
6591 return "NR (Numeric string, right separate sign)";
6592 case DSC__K_DTYPE_NRO
:
6593 return "NRO (Numeric string, right overpunched sig)";
6594 case DSC__K_DTYPE_NZ
:
6595 return "NZ (Numeric string, zoned sign)";
6596 case DSC__K_DTYPE_P
:
6597 return "P (Packed decimal string)";
6598 case DSC__K_DTYPE_ZI
:
6599 return "ZI (Sequence of instructions)";
6600 case DSC__K_DTYPE_ZEM
:
6601 return "ZEM (Procedure entry mask)";
6602 case DSC__K_DTYPE_DSC
:
6603 return "DSC (Descriptor, used for arrays of dyn strings)";
6604 case DSC__K_DTYPE_OU
:
6605 return "OU (Octaword logical)";
6606 case DSC__K_DTYPE_O
:
6607 return "O (Octaword integer)";
6608 case DSC__K_DTYPE_G
:
6609 return "G (Double precision G floating, 64 bit)";
6610 case DSC__K_DTYPE_H
:
6611 return "H (Quadruple precision floating, 128 bit)";
6612 case DSC__K_DTYPE_GC
:
6613 return "GC (Double precision complex, G floating)";
6614 case DSC__K_DTYPE_HC
:
6615 return "HC (Quadruple precision complex, H floating)";
6616 case DSC__K_DTYPE_CIT
:
6617 return "CIT (COBOL intermediate temporary)";
6618 case DSC__K_DTYPE_BPV
:
6619 return "BPV (Bound Procedure Value)";
6620 case DSC__K_DTYPE_BLV
:
6621 return "BLV (Bound Label Value)";
6622 case DSC__K_DTYPE_VU
:
6623 return "VU (Bit Unaligned)";
6624 case DSC__K_DTYPE_ADT
:
6625 return "ADT (Absolute Date-Time)";
6626 case DSC__K_DTYPE_VT
:
6627 return "VT (Varying Text)";
6628 case DSC__K_DTYPE_T2
:
6629 return "T2 (16-bit char)";
6630 case DSC__K_DTYPE_VT2
:
6631 return "VT2 (16-bit varying char)";
6633 return "?? (unknown)";
6638 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6640 unsigned char bclass
= buf
[3];
6641 unsigned char dtype
= buf
[2];
6642 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6643 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6645 evax_bfd_print_indent (indent
, file
);
6647 if (len
== 1 && pointer
== 0xffffffffUL
)
6650 fprintf (file
, _("64 bits *unhandled*\n"));
6654 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6655 bclass
, dtype
, len
, pointer
);
6658 case DSC__K_CLASS_NCA
:
6660 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6662 const unsigned char *b
;
6664 evax_bfd_print_indent (indent
, file
);
6665 fprintf (file
, _("non-contiguous array of %s\n"),
6666 evax_bfd_get_dsc_name (dsc
->dtype
));
6667 evax_bfd_print_indent (indent
+ 1, file
);
6669 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6670 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6671 evax_bfd_print_indent (indent
+ 1, file
);
6673 _("arsize: %u, a0: 0x%08x\n"),
6674 (unsigned)bfd_getl32 (dsc
->arsize
),
6675 (unsigned)bfd_getl32 (dsc
->a0
));
6676 evax_bfd_print_indent (indent
+ 1, file
);
6677 fprintf (file
, _("Strides:\n"));
6678 b
= buf
+ sizeof (*dsc
);
6679 for (i
= 0; i
< dsc
->dimct
; i
++)
6681 evax_bfd_print_indent (indent
+ 2, file
);
6682 fprintf (file
, _("[%u]: %u\n"), i
+ 1,
6683 (unsigned)bfd_getl32 (b
));
6686 evax_bfd_print_indent (indent
+ 1, file
);
6687 fprintf (file
, _("Bounds:\n"));
6688 b
= buf
+ sizeof (*dsc
);
6689 for (i
= 0; i
< dsc
->dimct
; i
++)
6691 evax_bfd_print_indent (indent
+ 2, file
);
6692 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6693 (unsigned)bfd_getl32 (b
+ 0),
6694 (unsigned)bfd_getl32 (b
+ 4));
6699 case DSC__K_CLASS_UBS
:
6701 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6703 evax_bfd_print_indent (indent
, file
);
6704 fprintf (file
, _("unaligned bit-string of %s\n"),
6705 evax_bfd_get_dsc_name (ubs
->dtype
));
6706 evax_bfd_print_indent (indent
+ 1, file
);
6708 _("base: %u, pos: %u\n"),
6709 (unsigned)bfd_getl32 (ubs
->base
),
6710 (unsigned)bfd_getl32 (ubs
->pos
));
6714 fprintf (file
, _("*unhandled*\n"));
6721 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6723 unsigned int vflags
= buf
[0];
6724 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6725 unsigned int len
= 5;
6727 evax_bfd_print_indent (indent
, file
);
6728 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6733 case DST__K_VFLAGS_NOVAL
:
6734 fprintf (file
, _("(no value)\n"));
6736 case DST__K_VFLAGS_NOTACTIVE
:
6737 fprintf (file
, _("(not active)\n"));
6739 case DST__K_VFLAGS_UNALLOC
:
6740 fprintf (file
, _("(not allocated)\n"));
6742 case DST__K_VFLAGS_DSC
:
6743 fprintf (file
, _("(descriptor)\n"));
6744 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6746 case DST__K_VFLAGS_TVS
:
6747 fprintf (file
, _("(trailing value)\n"));
6749 case DST__K_VS_FOLLOWS
:
6750 fprintf (file
, _("(value spec follows)\n"));
6752 case DST__K_VFLAGS_BITOFFS
:
6753 fprintf (file
, _("(at bit offset %u)\n"), value
);
6756 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6757 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6758 vflags
& DST__K_DISP
? 1 : 0,
6759 vflags
& DST__K_INDIR
? 1 : 0);
6760 switch (vflags
& DST__K_VALKIND_MASK
)
6762 case DST__K_VALKIND_LITERAL
:
6763 fputs (_("literal"), file
);
6765 case DST__K_VALKIND_ADDR
:
6766 fputs (_("address"), file
);
6768 case DST__K_VALKIND_DESC
:
6769 fputs (_("desc"), file
);
6771 case DST__K_VALKIND_REG
:
6772 fputs (_("reg"), file
);
6775 fputs (")\n", file
);
6782 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6784 unsigned char kind
= buf
[2];
6785 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6787 evax_bfd_print_indent (indent
, file
);
6788 fprintf (file
, ("len: %2u, kind: %2u "), len
, kind
);
6792 case DST__K_TS_ATOM
:
6793 fprintf (file
, ("atomic, type=0x%02x %s\n"),
6794 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6797 fprintf (file
, ("indirect, defined at 0x%08x\n"),
6798 (unsigned)bfd_getl32 (buf
));
6800 case DST__K_TS_TPTR
:
6801 fprintf (file
, ("typed pointer\n"));
6802 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6805 fprintf (file
, ("pointer\n"));
6807 case DST__K_TS_ARRAY
:
6809 const unsigned char *vs
;
6810 unsigned int vec_len
;
6813 fprintf (file
, ("array, dim: %u, bitmap: "), buf
[0]);
6814 vec_len
= (buf
[0] + 1 + 7) / 8;
6815 for (i
= 0; i
< vec_len
; i
++)
6816 fprintf (file
, " %02x", buf
[i
+ 1]);
6818 vs
= buf
+ 1 + vec_len
;
6819 evax_bfd_print_indent (indent
, file
);
6820 fprintf (file
, ("array descriptor:\n"));
6821 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6822 for (i
= 0; i
< buf
[0] + 1U; i
++)
6823 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6825 evax_bfd_print_indent (indent
, file
);
6827 fprintf (file
, ("type spec for element:\n"));
6829 fprintf (file
, ("type spec for subscript %u:\n"), i
);
6830 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6831 vs
+= bfd_getl16 (vs
);
6836 fprintf (file
, ("*unhandled*\n"));
6841 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6843 unsigned int off
= 0;
6844 unsigned int pc
= 0;
6845 unsigned int line
= 0;
6847 fprintf (file
, _("Debug symbol table:\n"));
6849 while (dst_size
> 0)
6851 struct vms_dst_header dsth
;
6856 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6858 fprintf (file
, _("cannot read DST header\n"));
6861 len
= bfd_getl16 (dsth
.length
);
6862 type
= bfd_getl16 (dsth
.type
);
6863 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
6873 len
-= sizeof (dsth
);
6874 buf
= bfd_malloc (len
);
6875 if (bfd_bread (buf
, len
, abfd
) != len
)
6877 fprintf (file
, _("cannot read DST symbol\n"));
6882 case DSC__K_DTYPE_V
:
6883 case DSC__K_DTYPE_BU
:
6884 case DSC__K_DTYPE_WU
:
6885 case DSC__K_DTYPE_LU
:
6886 case DSC__K_DTYPE_QU
:
6887 case DSC__K_DTYPE_B
:
6888 case DSC__K_DTYPE_W
:
6889 case DSC__K_DTYPE_L
:
6890 case DSC__K_DTYPE_Q
:
6891 case DSC__K_DTYPE_F
:
6892 case DSC__K_DTYPE_D
:
6893 case DSC__K_DTYPE_FC
:
6894 case DSC__K_DTYPE_DC
:
6895 case DSC__K_DTYPE_T
:
6896 case DSC__K_DTYPE_NU
:
6897 case DSC__K_DTYPE_NL
:
6898 case DSC__K_DTYPE_NLO
:
6899 case DSC__K_DTYPE_NR
:
6900 case DSC__K_DTYPE_NRO
:
6901 case DSC__K_DTYPE_NZ
:
6902 case DSC__K_DTYPE_P
:
6903 case DSC__K_DTYPE_ZI
:
6904 case DSC__K_DTYPE_ZEM
:
6905 case DSC__K_DTYPE_DSC
:
6906 case DSC__K_DTYPE_OU
:
6907 case DSC__K_DTYPE_O
:
6908 case DSC__K_DTYPE_G
:
6909 case DSC__K_DTYPE_H
:
6910 case DSC__K_DTYPE_GC
:
6911 case DSC__K_DTYPE_HC
:
6912 case DSC__K_DTYPE_CIT
:
6913 case DSC__K_DTYPE_BPV
:
6914 case DSC__K_DTYPE_BLV
:
6915 case DSC__K_DTYPE_VU
:
6916 case DSC__K_DTYPE_ADT
:
6917 case DSC__K_DTYPE_VT
:
6918 case DSC__K_DTYPE_T2
:
6919 case DSC__K_DTYPE_VT2
:
6920 fprintf (file
, _("standard data: %s\n"),
6921 evax_bfd_get_dsc_name (type
));
6922 evax_bfd_print_valspec (buf
, 4, file
);
6923 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
6927 struct vms_dst_modbeg
*dst
= (void *)buf
;
6928 const char *name
= (const char *)buf
+ sizeof (*dst
);
6930 fprintf (file
, _("modbeg\n"));
6931 fprintf (file
, _(" flags: %d, language: %u, "
6932 "major: %u, minor: %u\n"),
6934 (unsigned)bfd_getl32 (dst
->language
),
6935 (unsigned)bfd_getl16 (dst
->major
),
6936 (unsigned)bfd_getl16 (dst
->minor
));
6937 fprintf (file
, _(" module name: %.*s\n"),
6939 name
+= name
[0] + 1;
6940 fprintf (file
, _(" compiler : %.*s\n"),
6945 fprintf (file
, _("modend\n"));
6949 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
6950 const char *name
= (const char *)buf
+ sizeof (*dst
);
6952 fputs (_("rtnbeg\n"), file
);
6953 fprintf (file
, _(" flags: %u, address: 0x%08x, "
6954 "pd-address: 0x%08x\n"),
6956 (unsigned)bfd_getl32 (dst
->address
),
6957 (unsigned)bfd_getl32 (dst
->pd_address
));
6958 fprintf (file
, _(" routine name: %.*s\n"),
6964 struct vms_dst_rtnend
*dst
= (void *)buf
;
6966 fprintf (file
, _("rtnend: size 0x%08x\n"),
6967 (unsigned)bfd_getl32 (dst
->size
));
6972 struct vms_dst_prolog
*dst
= (void *)buf
;
6974 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
6975 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
6980 struct vms_dst_epilog
*dst
= (void *)buf
;
6982 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
6983 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
6988 struct vms_dst_blkbeg
*dst
= (void *)buf
;
6989 const char *name
= (const char *)buf
+ sizeof (*dst
);
6991 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6992 (unsigned)bfd_getl32 (dst
->address
),
6998 struct vms_dst_blkend
*dst
= (void *)buf
;
7000 fprintf (file
, _("blkend: size: 0x%08x\n"),
7001 (unsigned)bfd_getl32 (dst
->size
));
7004 case DST__K_TYPSPEC
:
7006 fprintf (file
, _("typspec (len: %u)\n"), len
);
7007 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
7008 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
7013 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
7014 evax_bfd_print_valspec (buf
, 4, file
);
7019 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
7020 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
7022 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
7023 evax_bfd_print_valspec (buf
, 4, file
);
7024 fprintf (file
, (" len: %u bits\n"),
7025 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
7029 fprintf (file
, _("recend\n"));
7031 case DST__K_ENUMBEG
:
7032 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
7033 buf
[0], buf
[1], buf
+ 2);
7035 case DST__K_ENUMELT
:
7036 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
7037 evax_bfd_print_valspec (buf
, 4, file
);
7039 case DST__K_ENUMEND
:
7040 fprintf (file
, _("enumend\n"));
7044 struct vms_dst_label
*lab
= (void *)buf
;
7045 fprintf (file
, ("label, name: %.*s\n"),
7046 lab
->name
[0], lab
->name
+ 1);
7047 fprintf (file
, (" address: 0x%08x\n"),
7048 (unsigned)bfd_getl32 (lab
->value
));
7051 case DST__K_DIS_RANGE
:
7053 unsigned int cnt
= bfd_getl32 (buf
);
7054 unsigned char *rng
= buf
+ 4;
7057 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7058 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7059 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7060 (unsigned)bfd_getl32 (rng
),
7061 (unsigned)bfd_getl32 (rng
+ 4));
7065 case DST__K_LINE_NUM
:
7067 unsigned char *buf_orig
= buf
;
7069 fprintf (file
, _("line num (len: %u)\n"), len
);
7074 unsigned char cmdlen
;
7084 case DST__K_DELTA_PC_W
:
7085 val
= bfd_getl16 (buf
+ 1);
7086 fprintf (file
, _("delta_pc_w %u\n"), val
);
7091 case DST__K_INCR_LINUM
:
7093 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7097 case DST__K_INCR_LINUM_W
:
7098 val
= bfd_getl16 (buf
+ 1);
7099 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7103 case DST__K_INCR_LINUM_L
:
7104 val
= bfd_getl32 (buf
+ 1);
7105 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7109 case DST__K_SET_LINUM
:
7110 line
= bfd_getl16 (buf
+ 1);
7111 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7114 case DST__K_SET_LINUM_B
:
7116 fprintf (file
, _("set_line_num_b %u\n"), line
);
7119 case DST__K_SET_LINUM_L
:
7120 line
= bfd_getl32 (buf
+ 1);
7121 fprintf (file
, _("set_line_num_l %u\n"), line
);
7124 case DST__K_SET_ABS_PC
:
7125 pc
= bfd_getl32 (buf
+ 1);
7126 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7129 case DST__K_DELTA_PC_L
:
7130 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7131 (unsigned)bfd_getl32 (buf
+ 1));
7135 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7137 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7141 val
= bfd_getl16 (buf
+ 1);
7142 fprintf (file
, _("term_w: 0x%04x"), val
);
7144 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7150 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7151 line
++; /* FIXME: curr increment. */
7153 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7158 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7171 unsigned char *buf_orig
= buf
;
7173 fprintf (file
, _("source (len: %u)\n"), len
);
7177 signed char cmd
= buf
[0];
7178 unsigned char cmdlen
= 0;
7182 case DST__K_SRC_DECLFILE
:
7184 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7187 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7189 src
->length
, src
->flags
,
7190 (unsigned)bfd_getl16 (src
->fileid
));
7191 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7192 "ebk: 0x%08x, ffb: 0x%04x, "
7194 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7195 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7196 (unsigned)bfd_getl32 (src
->rms_ebk
),
7197 (unsigned)bfd_getl16 (src
->rms_ffb
),
7199 name
= (const char *)buf
+ 1 + sizeof (*src
);
7200 fprintf (file
, _(" filename : %.*s\n"),
7202 name
+= name
[0] + 1;
7203 fprintf (file
, _(" module name: %.*s\n"),
7205 cmdlen
= 2 + src
->length
;
7208 case DST__K_SRC_SETFILE
:
7209 fprintf (file
, _(" setfile %u\n"),
7210 (unsigned)bfd_getl16 (buf
+ 1));
7213 case DST__K_SRC_SETREC_W
:
7214 fprintf (file
, _(" setrec %u\n"),
7215 (unsigned)bfd_getl16 (buf
+ 1));
7218 case DST__K_SRC_SETREC_L
:
7219 fprintf (file
, _(" setrec %u\n"),
7220 (unsigned)bfd_getl32 (buf
+ 1));
7223 case DST__K_SRC_SETLNUM_W
:
7224 fprintf (file
, _(" setlnum %u\n"),
7225 (unsigned)bfd_getl16 (buf
+ 1));
7228 case DST__K_SRC_SETLNUM_L
:
7229 fprintf (file
, _(" setlnum %u\n"),
7230 (unsigned)bfd_getl32 (buf
+ 1));
7233 case DST__K_SRC_DEFLINES_W
:
7234 fprintf (file
, _(" deflines %u\n"),
7235 (unsigned)bfd_getl16 (buf
+ 1));
7238 case DST__K_SRC_DEFLINES_B
:
7239 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7242 case DST__K_SRC_FORMFEED
:
7243 fprintf (file
, _(" formfeed\n"));
7247 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7259 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7267 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7269 struct vms_eihd eihd
;
7272 unsigned int eiha_off
;
7273 unsigned int eihi_off
;
7274 unsigned int eihs_off
;
7275 unsigned int eisd_off
;
7276 unsigned int eihef_off
= 0;
7277 unsigned int eihnp_off
= 0;
7278 unsigned int dmt_vbn
= 0;
7279 unsigned int dmt_size
= 0;
7280 unsigned int dst_vbn
= 0;
7281 unsigned int dst_size
= 0;
7282 unsigned int gst_vbn
= 0;
7283 unsigned int gst_size
= 0;
7284 unsigned int eiaf_vbn
= 0;
7285 unsigned int eiaf_size
= 0;
7286 unsigned int eihvn_off
;
7288 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7289 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7291 fprintf (file
, _("cannot read EIHD\n"));
7294 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7295 (unsigned)bfd_getl32 (eihd
.size
),
7296 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7297 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7298 (unsigned)bfd_getl32 (eihd
.majorid
),
7299 (unsigned)bfd_getl32 (eihd
.minorid
));
7301 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7305 name
= _("executable");
7308 name
= _("linkable image");
7311 name
= _("unknown");
7314 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7316 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7319 case EIHD__C_NATIVE
:
7326 name
= _("unknown");
7329 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7331 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7332 eiha_off
= bfd_getl32 (eihd
.activoff
);
7333 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7334 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7335 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7336 "imgid: %u, patch: %u\n"),
7337 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7338 (unsigned)bfd_getl32 (eihd
.patchoff
));
7339 fprintf (file
, _(" fixup info rva: "));
7340 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7341 fprintf (file
, _(", symbol vector rva: "));
7342 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7343 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7344 fprintf (file
, _("\n"
7345 " version array off: %u\n"),
7348 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7349 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7350 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7351 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7352 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7353 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7354 fprintf (file
, _(" linker flags: %08x:"), val
);
7355 if (val
& EIHD__M_LNKDEBUG
)
7356 fprintf (file
, " LNKDEBUG");
7357 if (val
& EIHD__M_LNKNOTFR
)
7358 fprintf (file
, " LNKNOTFR");
7359 if (val
& EIHD__M_NOP0BUFS
)
7360 fprintf (file
, " NOP0BUFS");
7361 if (val
& EIHD__M_PICIMG
)
7362 fprintf (file
, " PICIMG");
7363 if (val
& EIHD__M_P0IMAGE
)
7364 fprintf (file
, " P0IMAGE");
7365 if (val
& EIHD__M_DBGDMT
)
7366 fprintf (file
, " DBGDMT");
7367 if (val
& EIHD__M_INISHR
)
7368 fprintf (file
, " INISHR");
7369 if (val
& EIHD__M_XLATED
)
7370 fprintf (file
, " XLATED");
7371 if (val
& EIHD__M_BIND_CODE_SEC
)
7372 fprintf (file
, " BIND_CODE_SEC");
7373 if (val
& EIHD__M_BIND_DATA_SEC
)
7374 fprintf (file
, " BIND_DATA_SEC");
7375 if (val
& EIHD__M_MKTHREADS
)
7376 fprintf (file
, " MKTHREADS");
7377 if (val
& EIHD__M_UPCALLS
)
7378 fprintf (file
, " UPCALLS");
7379 if (val
& EIHD__M_OMV_READY
)
7380 fprintf (file
, " OMV_READY");
7381 if (val
& EIHD__M_EXT_BIND_SECT
)
7382 fprintf (file
, " EXT_BIND_SECT");
7383 fprintf (file
, "\n");
7384 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7385 "match ctrl: %u, symvect_size: %u\n"),
7386 (unsigned)bfd_getl32 (eihd
.ident
),
7387 (unsigned)bfd_getl32 (eihd
.sysver
),
7389 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7390 fprintf (file
, _(" BPAGE: %u"),
7391 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7392 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7394 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7395 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7396 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7397 eihef_off
, eihnp_off
);
7399 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7403 struct vms_eihvn eihvn
;
7407 fprintf (file
, _("system version array information:\n"));
7408 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7409 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7411 fprintf (file
, _("cannot read EIHVN header\n"));
7414 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7415 for (j
= 0; j
< 32; j
++)
7416 if (mask
& (1 << j
))
7418 struct vms_eihvn_subversion ver
;
7419 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7421 fprintf (file
, _("cannot read EIHVN version\n"));
7424 fprintf (file
, _(" %02u "), j
);
7427 case EIHVN__BASE_IMAGE_BIT
:
7428 fputs (_("BASE_IMAGE "), file
);
7430 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7431 fputs (_("MEMORY_MANAGEMENT"), file
);
7434 fputs (_("IO "), file
);
7436 case EIHVN__FILES_VOLUMES_BIT
:
7437 fputs (_("FILES_VOLUMES "), file
);
7439 case EIHVN__PROCESS_SCHED_BIT
:
7440 fputs (_("PROCESS_SCHED "), file
);
7442 case EIHVN__SYSGEN_BIT
:
7443 fputs (_("SYSGEN "), file
);
7445 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7446 fputs (_("CLUSTERS_LOCKMGR "), file
);
7448 case EIHVN__LOGICAL_NAMES_BIT
:
7449 fputs (_("LOGICAL_NAMES "), file
);
7451 case EIHVN__SECURITY_BIT
:
7452 fputs (_("SECURITY "), file
);
7454 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7455 fputs (_("IMAGE_ACTIVATOR "), file
);
7457 case EIHVN__NETWORKS_BIT
:
7458 fputs (_("NETWORKS "), file
);
7460 case EIHVN__COUNTERS_BIT
:
7461 fputs (_("COUNTERS "), file
);
7463 case EIHVN__STABLE_BIT
:
7464 fputs (_("STABLE "), file
);
7466 case EIHVN__MISC_BIT
:
7467 fputs (_("MISC "), file
);
7469 case EIHVN__CPU_BIT
:
7470 fputs (_("CPU "), file
);
7472 case EIHVN__VOLATILE_BIT
:
7473 fputs (_("VOLATILE "), file
);
7475 case EIHVN__SHELL_BIT
:
7476 fputs (_("SHELL "), file
);
7478 case EIHVN__POSIX_BIT
:
7479 fputs (_("POSIX "), file
);
7481 case EIHVN__MULTI_PROCESSING_BIT
:
7482 fputs (_("MULTI_PROCESSING "), file
);
7484 case EIHVN__GALAXY_BIT
:
7485 fputs (_("GALAXY "), file
);
7488 fputs (_("*unknown* "), file
);
7491 fprintf (file
, _(": %u.%u\n"),
7492 (unsigned)bfd_getl16 (ver
.major
),
7493 (unsigned)bfd_getl16 (ver
.minor
));
7499 struct vms_eiha eiha
;
7501 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7502 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7504 fprintf (file
, _("cannot read EIHA\n"));
7507 fprintf (file
, _("Image activation: (size=%u)\n"),
7508 (unsigned)bfd_getl32 (eiha
.size
));
7509 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7510 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7511 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7512 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7513 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7514 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7515 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7516 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7517 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7518 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7519 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7520 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7521 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7522 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7523 (unsigned)bfd_getl32 (eiha
.inishr
));
7527 struct vms_eihi eihi
;
7529 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7530 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7532 fprintf (file
, _("cannot read EIHI\n"));
7535 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7536 (unsigned)bfd_getl32 (eihi
.majorid
),
7537 (unsigned)bfd_getl32 (eihi
.minorid
));
7538 fprintf (file
, _(" image name : %.*s\n"),
7539 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7540 fprintf (file
, _(" link time : %s\n"),
7541 vms_time_to_str (eihi
.linktime
));
7542 fprintf (file
, _(" image ident : %.*s\n"),
7543 eihi
.imgid
[0], eihi
.imgid
+ 1);
7544 fprintf (file
, _(" linker ident : %.*s\n"),
7545 eihi
.linkid
[0], eihi
.linkid
+ 1);
7546 fprintf (file
, _(" image build ident: %.*s\n"),
7547 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7551 struct vms_eihs eihs
;
7553 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7554 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7556 fprintf (file
, _("cannot read EIHS\n"));
7559 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7560 (unsigned)bfd_getl32 (eihs
.majorid
),
7561 (unsigned)bfd_getl32 (eihs
.minorid
));
7562 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7563 dst_size
= bfd_getl32 (eihs
.dstsize
);
7564 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7565 dst_vbn
, dst_size
, dst_size
);
7566 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7567 gst_size
= bfd_getl32 (eihs
.gstsize
);
7568 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7570 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7571 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7572 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7575 while (eisd_off
!= 0)
7577 struct vms_eisd eisd
;
7582 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7583 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7585 fprintf (file
, _("cannot read EISD\n"));
7588 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7589 if (len
!= (unsigned)-1)
7593 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7595 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7596 "size: %u, offset: %u)\n"),
7597 (unsigned)bfd_getl32 (eisd
.majorid
),
7598 (unsigned)bfd_getl32 (eisd
.minorid
),
7602 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7603 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7604 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7605 (unsigned)bfd_getl32 (eisd
.secsize
));
7606 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7607 fprintf (file
, _(" flags: 0x%04x"), val
);
7608 if (val
& EISD__M_GBL
)
7609 fprintf (file
, " GBL");
7610 if (val
& EISD__M_CRF
)
7611 fprintf (file
, " CRF");
7612 if (val
& EISD__M_DZRO
)
7613 fprintf (file
, " DZRO");
7614 if (val
& EISD__M_WRT
)
7615 fprintf (file
, " WRT");
7616 if (val
& EISD__M_INITALCODE
)
7617 fprintf (file
, " INITALCODE");
7618 if (val
& EISD__M_BASED
)
7619 fprintf (file
, " BASED");
7620 if (val
& EISD__M_FIXUPVEC
)
7621 fprintf (file
, " FIXUPVEC");
7622 if (val
& EISD__M_RESIDENT
)
7623 fprintf (file
, " RESIDENT");
7624 if (val
& EISD__M_VECTOR
)
7625 fprintf (file
, " VECTOR");
7626 if (val
& EISD__M_PROTECT
)
7627 fprintf (file
, " PROTECT");
7628 if (val
& EISD__M_LASTCLU
)
7629 fprintf (file
, " LASTCLU");
7630 if (val
& EISD__M_EXE
)
7631 fprintf (file
, " EXE");
7632 if (val
& EISD__M_NONSHRADR
)
7633 fprintf (file
, " NONSHRADR");
7634 if (val
& EISD__M_QUAD_LENGTH
)
7635 fprintf (file
, " QUAD_LENGTH");
7636 if (val
& EISD__M_ALLOC_64BIT
)
7637 fprintf (file
, " ALLOC_64BIT");
7638 fprintf (file
, "\n");
7639 if (val
& EISD__M_FIXUPVEC
)
7641 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7642 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7644 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7645 (unsigned)bfd_getl32 (eisd
.vbn
),
7646 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7649 case EISD__K_NORMAL
:
7650 fputs (_("NORMAL"), file
);
7652 case EISD__K_SHRFXD
:
7653 fputs (_("SHRFXD"), file
);
7655 case EISD__K_PRVFXD
:
7656 fputs (_("PRVFXD"), file
);
7658 case EISD__K_SHRPIC
:
7659 fputs (_("SHRPIC"), file
);
7661 case EISD__K_PRVPIC
:
7662 fputs (_("PRVPIC"), file
);
7664 case EISD__K_USRSTACK
:
7665 fputs (_("USRSTACK"), file
);
7668 fputs (_("*unknown*"), file
);
7671 fputs (_(")\n"), file
);
7672 if (val
& EISD__M_GBL
)
7673 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7674 (unsigned)bfd_getl32 (eisd
.ident
),
7675 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7681 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7683 fprintf (file
, _("cannot read DMT\n"));
7687 fprintf (file
, _("Debug module table:\n"));
7689 while (dmt_size
> 0)
7691 struct vms_dmt_header dmth
;
7694 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7696 fprintf (file
, _("cannot read DMT header\n"));
7699 count
= bfd_getl16 (dmth
.psect_count
);
7701 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7702 (unsigned)bfd_getl32 (dmth
.modbeg
),
7703 (unsigned)bfd_getl32 (dmth
.size
), count
);
7704 dmt_size
-= sizeof (dmth
);
7707 struct vms_dmt_psect dmtp
;
7709 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7711 fprintf (file
, _("cannot read DMT psect\n"));
7714 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7715 (unsigned)bfd_getl32 (dmtp
.start
),
7716 (unsigned)bfd_getl32 (dmtp
.length
));
7718 dmt_size
-= sizeof (dmtp
);
7725 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7727 fprintf (file
, _("cannot read DST\n"));
7731 evax_bfd_print_dst (abfd
, dst_size
, file
);
7735 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7737 fprintf (file
, _("cannot read GST\n"));
7741 fprintf (file
, _("Global symbol table:\n"));
7742 evax_bfd_print_eobj (abfd
, file
);
7747 struct vms_eiaf
*eiaf
;
7748 unsigned int qrelfixoff
;
7749 unsigned int lrelfixoff
;
7750 unsigned int qdotadroff
;
7751 unsigned int ldotadroff
;
7752 unsigned int shrimgcnt
;
7753 unsigned int shlstoff
;
7754 unsigned int codeadroff
;
7755 unsigned int lpfixoff
;
7756 unsigned int chgprtoff
;
7758 buf
= bfd_malloc (eiaf_size
);
7760 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7761 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7763 fprintf (file
, _("cannot read EIHA\n"));
7767 eiaf
= (struct vms_eiaf
*)buf
;
7769 _("Image activator fixup: (major: %u, minor: %u)\n"),
7770 (unsigned)bfd_getl32 (eiaf
->majorid
),
7771 (unsigned)bfd_getl32 (eiaf
->minorid
));
7772 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7773 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7774 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7775 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7776 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7777 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7778 fprintf (file
, _(" size : %u\n"),
7779 (unsigned)bfd_getl32 (eiaf
->size
));
7780 fprintf (file
, _(" flags: 0x%08x\n"),
7781 (unsigned)bfd_getl32 (eiaf
->flags
));
7782 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7783 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7784 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7785 qrelfixoff
, lrelfixoff
);
7786 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7787 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7788 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7789 qdotadroff
, ldotadroff
);
7790 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7791 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7792 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7793 codeadroff
, lpfixoff
);
7794 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7795 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7796 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7797 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7798 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7799 shlstoff
, shrimgcnt
);
7800 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7801 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7802 (unsigned)bfd_getl32 (eiaf
->permctx
));
7803 fprintf (file
, _(" base_va : 0x%08x\n"),
7804 (unsigned)bfd_getl32 (eiaf
->base_va
));
7805 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7806 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7810 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7813 fprintf (file
, _(" Shareable images:\n"));
7814 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7817 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7818 j
, shl
->size
, shl
->flags
,
7819 shl
->imgnam
[0], shl
->imgnam
+ 1);
7822 if (qrelfixoff
!= 0)
7824 fprintf (file
, _(" quad-word relocation fixups:\n"));
7825 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7827 if (lrelfixoff
!= 0)
7829 fprintf (file
, _(" long-word relocation fixups:\n"));
7830 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
7832 if (qdotadroff
!= 0)
7834 fprintf (file
, _(" quad-word .address reference fixups:\n"));
7835 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
7837 if (ldotadroff
!= 0)
7839 fprintf (file
, _(" long-word .address reference fixups:\n"));
7840 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
7842 if (codeadroff
!= 0)
7844 fprintf (file
, _(" Code Address Reference Fixups:\n"));
7845 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
7849 fprintf (file
, _(" Linkage Pairs Referece Fixups:\n"));
7850 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
7854 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
7855 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
7858 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
7859 for (j
= 0; j
< count
; j
++, eicp
++)
7861 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
7863 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7864 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
7865 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
7866 (unsigned)bfd_getl32 (eicp
->size
),
7867 (unsigned)bfd_getl32 (eicp
->newprt
));
7871 fprintf (file
, "NA");
7873 case PRT__C_RESERVED
:
7874 fprintf (file
, "RES");
7877 fprintf (file
, "KW");
7880 fprintf (file
, "KR");
7883 fprintf (file
, "UW");
7886 fprintf (file
, "EW");
7889 fprintf (file
, "ERKW");
7892 fprintf (file
, "ER");
7895 fprintf (file
, "SW");
7898 fprintf (file
, "SREW");
7901 fprintf (file
, "SRKW");
7904 fprintf (file
, "SR");
7907 fprintf (file
, "URSW");
7910 fprintf (file
, "UREW");
7913 fprintf (file
, "URKW");
7916 fprintf (file
, "UR");
7930 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
7932 FILE *file
= (FILE *)ptr
;
7934 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
7935 evax_bfd_print_image (abfd
, file
);
7938 if (bfd_seek (abfd
, 0, SEEK_SET
))
7940 evax_bfd_print_eobj (abfd
, file
);
7947 /* Slurp ETIR/EDBG/ETBT VMS object records. */
7950 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
7952 asection
*cur_section
;
7953 file_ptr cur_offset
;
7954 asection
*dst_section
;
7955 file_ptr dst_offset
;
7957 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
7963 dst_section
= PRIV (dst_section
);
7967 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
7969 /* Discard the DST section. */
7973 else if (dst_section
)
7975 dst_offset
= dst_section
->output_offset
;
7976 dst_section
= dst_section
->output_section
;
7985 type
= _bfd_vms_get_object_record (abfd
);
7988 vms_debug2 ((2, "next_record failed\n"));
7994 PRIV (image_section
) = cur_section
;
7995 PRIV (image_offset
) = cur_offset
;
7996 res
= _bfd_vms_slurp_etir (abfd
, info
);
7997 cur_section
= PRIV (image_section
);
7998 cur_offset
= PRIV (image_offset
);
8002 if (dst_section
== NULL
)
8004 PRIV (image_section
) = dst_section
;
8005 PRIV (image_offset
) = dst_offset
;
8006 res
= _bfd_vms_slurp_etir (abfd
, info
);
8007 dst_offset
= PRIV (image_offset
);
8016 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
8023 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
8024 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8029 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
8032 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8034 struct alpha_vms_shlib_el
*sl
;
8035 asection
*sect
= PRIV2 (src
, image_section
);
8036 file_ptr offset
= PRIV2 (src
, image_offset
);
8038 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8039 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8040 sl
->has_fixups
= TRUE
;
8041 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8042 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8043 sect
->output_section
->flags
|= SEC_RELOC
;
8046 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
8049 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8051 struct alpha_vms_shlib_el
*sl
;
8052 asection
*sect
= PRIV2 (src
, image_section
);
8053 file_ptr offset
= PRIV2 (src
, image_offset
);
8055 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8056 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8057 sl
->has_fixups
= TRUE
;
8058 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8059 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8060 sect
->output_section
->flags
|= SEC_RELOC
;
8063 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
8066 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8067 bfd
*shlib
, bfd_vma vec
)
8069 struct alpha_vms_shlib_el
*sl
;
8070 struct alpha_vms_vma_ref
*r
;
8071 asection
*sect
= PRIV2 (src
, image_section
);
8072 file_ptr offset
= PRIV2 (src
, image_offset
);
8074 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8075 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8076 sl
->has_fixups
= TRUE
;
8077 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8078 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8080 sect
->output_section
->flags
|= SEC_RELOC
;
8084 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8085 unsigned int shr ATTRIBUTE_UNUSED
,
8086 bfd_vma vec ATTRIBUTE_UNUSED
)
8088 /* Not yet supported. */
8092 /* Add relocation. FIXME: Not yet emitted. */
8095 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8100 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8104 static struct bfd_hash_entry
*
8105 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8106 struct bfd_hash_table
*table
,
8109 struct alpha_vms_link_hash_entry
*ret
=
8110 (struct alpha_vms_link_hash_entry
*) entry
;
8112 /* Allocate the structure if it has not already been allocated by a
8115 ret
= ((struct alpha_vms_link_hash_entry
*)
8116 bfd_hash_allocate (table
,
8117 sizeof (struct alpha_vms_link_hash_entry
)));
8121 /* Call the allocation method of the superclass. */
8122 ret
= ((struct alpha_vms_link_hash_entry
*)
8123 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8128 return (struct bfd_hash_entry
*) ret
;
8131 /* Create an Alpha/VMS link hash table. */
8133 static struct bfd_link_hash_table
*
8134 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8136 struct alpha_vms_link_hash_table
*ret
;
8137 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8139 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8142 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8143 alpha_vms_link_hash_newfunc
,
8144 sizeof (struct alpha_vms_link_hash_entry
)))
8150 VEC_INIT (ret
->shrlibs
);
8157 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8161 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8163 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8164 struct alpha_vms_link_hash_entry
*h
;
8165 struct bfd_link_hash_entry
*h_root
;
8168 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8171 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8173 /* In selective_search mode, only add definition that are
8175 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8176 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8177 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8183 h_root
= (struct bfd_link_hash_entry
*) h
;
8184 if (_bfd_generic_link_add_one_symbol
8185 (info
, abfd
, sym
.name
, sym
.flags
, sym
.section
, sym
.value
,
8186 NULL
, FALSE
, FALSE
, &h_root
) == FALSE
)
8188 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8190 if ((e
->flags
& EGSY__V_DEF
)
8192 && abfd
->xvec
== info
->output_bfd
->xvec
)
8196 if (abfd
->flags
& DYNAMIC
)
8198 struct alpha_vms_shlib_el
*shlib
;
8200 /* We do not want to include any of the sections in a dynamic
8201 object in the output file. See comment in elflink.c. */
8202 bfd_section_list_clear (abfd
);
8204 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8205 struct alpha_vms_shlib_el
);
8207 VEC_INIT (shlib
->ca
);
8208 VEC_INIT (shlib
->lp
);
8209 VEC_INIT (shlib
->qr
);
8210 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8217 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8220 struct bfd_link_hash_entry
**pundef
;
8221 struct bfd_link_hash_entry
**next_pundef
;
8223 /* We only accept VMS libraries. */
8224 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8226 bfd_set_error (bfd_error_wrong_format
);
8230 /* The archive_pass field in the archive itself is used to
8231 initialize PASS, since we may search the same archive multiple
8233 pass
= ++abfd
->archive_pass
;
8235 /* Look through the list of undefined symbols. */
8236 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8238 struct bfd_link_hash_entry
*h
;
8244 next_pundef
= &(*pundef
)->u
.undef
.next
;
8246 /* When a symbol is defined, it is not necessarily removed from
8248 if (h
->type
!= bfd_link_hash_undefined
8249 && h
->type
!= bfd_link_hash_common
)
8251 /* Remove this entry from the list, for general cleanliness
8252 and because we are going to look through the list again
8253 if we search any more libraries. We can't remove the
8254 entry if it is the tail, because that would lose any
8255 entries we add to the list later on. */
8256 if (*pundef
!= info
->hash
->undefs_tail
)
8258 *pundef
= *next_pundef
;
8259 next_pundef
= pundef
;
8264 /* Look for this symbol in the archive hash table. */
8265 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8266 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8268 /* Nothing in this slot. */
8272 element
= bfd_get_elt_at_index (abfd
, symidx
);
8273 if (element
== NULL
)
8276 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8278 /* Next symbol if this archive is wrong or already handled. */
8282 if (! bfd_check_format (element
, bfd_object
))
8284 element
->archive_pass
= -1;
8288 orig_element
= element
;
8289 if (bfd_is_thin_archive (abfd
))
8291 element
= _bfd_vms_lib_get_imagelib_file (element
);
8292 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8294 orig_element
->archive_pass
= -1;
8299 /* Unlike the generic linker, we know that this element provides
8300 a definition for an undefined symbol and we know that we want
8301 to include it. We don't need to check anything. */
8302 if (!(*info
->callbacks
8303 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8305 if (!alpha_vms_link_add_object_symbols (element
, info
))
8308 orig_element
->archive_pass
= pass
;
8315 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8317 switch (bfd_get_format (abfd
))
8320 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8322 return alpha_vms_link_add_object_symbols (abfd
, info
);
8325 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8327 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8330 bfd_set_error (bfd_error_wrong_format
);
8336 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8338 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8339 unsigned char *content
;
8341 unsigned int sz
= 0;
8342 unsigned int lp_sz
= 0;
8343 unsigned int ca_sz
= 0;
8344 unsigned int qr_sz
= 0;
8345 unsigned int shrimg_cnt
= 0;
8346 unsigned int chgprt_num
= 0;
8347 unsigned int chgprt_sz
= 0;
8348 struct vms_eiaf
*eiaf
;
8352 /* Shared libraries. */
8353 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8355 struct alpha_vms_shlib_el
*shlib
;
8357 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8359 if (!shlib
->has_fixups
)
8364 if (VEC_COUNT (shlib
->ca
) > 0)
8366 /* Header + entries. */
8368 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8370 if (VEC_COUNT (shlib
->lp
) > 0)
8372 /* Header + entries. */
8374 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8376 if (VEC_COUNT (shlib
->qr
) > 0)
8378 /* Header + entries. */
8380 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8391 /* Finish now if there is no content. */
8392 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8395 /* Add an eicp entry for the fixup itself. */
8397 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8399 /* This isect could be made RO or EXE after relocations are applied. */
8400 if ((sec
->flags
& SEC_RELOC
) != 0
8401 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8404 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8406 /* Allocate section content (round-up size) */
8407 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8408 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8409 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8410 content
= bfd_zalloc (info
->output_bfd
, sz
);
8411 if (content
== NULL
)
8414 sec
= alpha_vms_link_hash (info
)->fixup
;
8415 sec
->contents
= content
;
8418 eiaf
= (struct vms_eiaf
*)content
;
8419 off
= sizeof (struct vms_eiaf
);
8420 bfd_putl32 (0, eiaf
->majorid
);
8421 bfd_putl32 (0, eiaf
->minorid
);
8422 bfd_putl32 (0, eiaf
->iaflink
);
8423 bfd_putl32 (0, eiaf
->fixuplnk
);
8424 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8425 bfd_putl32 (0, eiaf
->flags
);
8426 bfd_putl32 (0, eiaf
->qrelfixoff
);
8427 bfd_putl32 (0, eiaf
->lrelfixoff
);
8428 bfd_putl32 (0, eiaf
->qdotadroff
);
8429 bfd_putl32 (0, eiaf
->ldotadroff
);
8430 bfd_putl32 (0, eiaf
->codeadroff
);
8431 bfd_putl32 (0, eiaf
->lpfixoff
);
8432 bfd_putl32 (0, eiaf
->chgprtoff
);
8433 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8434 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8435 bfd_putl32 (0, eiaf
->shlextra
);
8436 bfd_putl32 (0, eiaf
->permctx
);
8437 bfd_putl32 (0, eiaf
->base_va
);
8438 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8445 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8447 struct alpha_vms_shlib_el
*shlib
;
8448 struct vms_shl
*shl
;
8450 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8452 if (!shlib
->has_fixups
)
8455 /* Renumber shared images. */
8456 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8458 shl
= (struct vms_shl
*)(content
+ off
);
8459 bfd_putl32 (0, shl
->baseva
);
8460 bfd_putl32 (0, shl
->shlptr
);
8461 bfd_putl32 (0, shl
->ident
);
8462 bfd_putl32 (0, shl
->permctx
);
8463 shl
->size
= sizeof (struct vms_shl
);
8464 bfd_putl16 (0, shl
->fill_1
);
8466 bfd_putl32 (0, shl
->icb
);
8467 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8468 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8471 off
+= sizeof (struct vms_shl
);
8477 bfd_putl32 (off
, eiaf
->codeadroff
);
8479 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8481 struct alpha_vms_shlib_el
*shlib
;
8484 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8486 if (VEC_COUNT (shlib
->ca
) == 0)
8489 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8490 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8493 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8495 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8501 bfd_putl32 (0, content
+ off
);
8502 bfd_putl32 (0, content
+ off
+ 4);
8509 bfd_putl32 (off
, eiaf
->lpfixoff
);
8511 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8513 struct alpha_vms_shlib_el
*shlib
;
8516 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8518 if (VEC_COUNT (shlib
->lp
) == 0)
8521 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8522 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8525 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8527 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8533 bfd_putl32 (0, content
+ off
);
8534 bfd_putl32 (0, content
+ off
+ 4);
8541 bfd_putl32 (off
, eiaf
->qdotadroff
);
8543 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8545 struct alpha_vms_shlib_el
*shlib
;
8548 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8550 if (VEC_COUNT (shlib
->qr
) == 0)
8553 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8554 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8557 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8559 struct alpha_vms_vma_ref
*r
;
8560 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8561 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8562 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8567 bfd_putl32 (0, content
+ off
);
8568 bfd_putl32 (0, content
+ off
+ 4);
8573 /* Write the change protection table. */
8574 bfd_putl32 (off
, eiaf
->chgprtoff
);
8575 bfd_putl32 (chgprt_num
, content
+ off
);
8578 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8580 struct vms_eicp
*eicp
;
8583 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8584 strcmp (sec
->name
, "$FIXUP$") == 0)
8586 else if ((sec
->flags
& SEC_RELOC
) != 0
8587 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8592 eicp
= (struct vms_eicp
*)(content
+ off
);
8593 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8594 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8596 bfd_putl32 (prot
, eicp
->newprt
);
8597 off
+= sizeof (struct vms_eicp
);
8603 /* Called by bfd_link_hash_traverse to fill the symbol table.
8604 Return FALSE in case of failure. */
8607 alpha_vms_link_output_symbol (struct bfd_link_hash_entry
*hc
, void *infov
)
8609 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8610 struct alpha_vms_link_hash_entry
*h
= (struct alpha_vms_link_hash_entry
*)hc
;
8611 struct vms_symbol_entry
*sym
;
8613 switch (h
->root
.type
)
8615 case bfd_link_hash_undefined
:
8617 case bfd_link_hash_new
:
8619 case bfd_link_hash_undefweak
:
8621 case bfd_link_hash_defined
:
8622 case bfd_link_hash_defweak
:
8624 asection
*sec
= h
->root
.u
.def
.section
;
8626 /* FIXME: this is certainly a symbol from a dynamic library. */
8627 if (bfd_is_abs_section (sec
))
8630 if (sec
->owner
->flags
& DYNAMIC
)
8634 case bfd_link_hash_common
:
8636 case bfd_link_hash_indirect
:
8637 case bfd_link_hash_warning
:
8641 /* Do not write not kept symbols. */
8642 if (info
->strip
== strip_some
8643 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8644 FALSE
, FALSE
) != NULL
)
8649 /* This symbol doesn't come from a VMS object. So we suppose it is
8651 int len
= strlen (h
->root
.root
.string
);
8653 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8654 sizeof (*sym
) + len
);
8658 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8660 sym
->owner
= info
->output_bfd
;
8662 sym
->typ
= EGSD__C_SYMG
;
8664 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8665 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8666 sym
->section
= h
->root
.u
.def
.section
;
8667 sym
->value
= h
->root
.u
.def
.value
;
8672 if (!add_symbol_entry (info
->output_bfd
, sym
))
8679 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8682 struct bfd_link_order
*p
;
8690 if (info
->relocatable
)
8692 /* FIXME: we do not yet support relocatable link. It is not obvious
8693 how to do it for debug infos. */
8694 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8698 bfd_get_outsymbols (abfd
) = NULL
;
8699 bfd_get_symcount (abfd
) = 0;
8701 /* Mark all sections which will be included in the output file. */
8702 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8703 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8704 if (p
->type
== bfd_indirect_link_order
)
8705 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8708 /* Handle all the link order information for the sections. */
8709 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8711 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8712 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8714 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8716 printf (" at 0x%08x - 0x%08x: ",
8717 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8720 case bfd_section_reloc_link_order
:
8721 case bfd_symbol_reloc_link_order
:
8722 printf (" section/symbol reloc\n");
8724 case bfd_indirect_link_order
:
8725 printf (" section %s of %s\n",
8726 p
->u
.indirect
.section
->name
,
8727 p
->u
.indirect
.section
->owner
->filename
);
8729 case bfd_data_link_order
:
8730 printf (" explicit data\n");
8733 printf (" *unknown* type %u\n", p
->type
);
8740 /* Generate the symbol table. */
8741 BFD_ASSERT (PRIV (syms
) == NULL
);
8742 if (info
->strip
!= strip_all
)
8743 bfd_link_hash_traverse (info
->hash
, alpha_vms_link_output_symbol
, info
);
8745 /* Find the entry point. */
8746 if (bfd_get_start_address (abfd
) == 0)
8748 bfd
*startbfd
= NULL
;
8750 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8752 /* Consider only VMS object files. */
8753 if (sub
->xvec
!= abfd
->xvec
)
8756 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8758 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8760 if (startbfd
!= NULL
8761 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8763 (*info
->callbacks
->einfo
)
8764 (_("%P: multiple entry points: in modules %B and %B\n"),
8773 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8774 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8777 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8779 bfd_set_start_address
8780 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8784 /* Set transfer addresses. */
8787 struct bfd_link_hash_entry
*h
;
8790 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
8791 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
8792 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
8793 PRIV (transfer_address
[i
++]) =
8794 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
8795 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
8797 PRIV (transfer_address
[i
++]) = 0;
8800 /* Allocate contents.
8801 Also compute the virtual base address. */
8802 base_addr
= (bfd_vma
)-1;
8804 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8806 if (o
->flags
& SEC_HAS_CONTENTS
)
8808 o
->contents
= bfd_alloc (abfd
, o
->size
);
8809 if (o
->contents
== NULL
)
8812 if (o
->flags
& SEC_LOAD
)
8814 if (o
->vma
< base_addr
)
8816 if (o
->vma
+ o
->size
> last_addr
)
8817 last_addr
= o
->vma
+ o
->size
;
8819 /* Clear the RELOC flags. Currently we don't support incremental
8820 linking. We use the RELOC flag for computing the eicp entries. */
8821 o
->flags
&= ~SEC_RELOC
;
8824 /* Create the fixup section. */
8825 fixupsec
= bfd_make_section_anyway_with_flags
8826 (info
->output_bfd
, "$FIXUP$",
8827 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8828 if (fixupsec
== NULL
)
8830 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
8831 fixupsec
->vma
= last_addr
;
8833 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
8834 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
8836 /* Create the DMT section, if necessary. */
8837 BFD_ASSERT (PRIV (dst_section
) == NULL
);
8838 dst
= bfd_get_section_by_name (abfd
, "$DST$");
8839 if (dst
!= NULL
&& dst
->size
== 0)
8843 PRIV (dst_section
) = dst
;
8844 dmt
= bfd_make_section_anyway_with_flags
8845 (info
->output_bfd
, "$DMT$",
8846 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8853 /* Read all sections from the inputs. */
8854 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8856 if (sub
->flags
& DYNAMIC
)
8858 alpha_vms_create_eisd_for_shared (abfd
, sub
);
8862 if (!alpha_vms_read_sections_content (sub
, info
))
8866 /* Handle all the link order information for the sections.
8867 Note: past this point, it is not possible to create new sections. */
8868 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8870 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8874 case bfd_section_reloc_link_order
:
8875 case bfd_symbol_reloc_link_order
:
8878 case bfd_indirect_link_order
:
8882 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
8889 /* Compute fixups. */
8890 if (!alpha_vms_build_fixups (info
))
8893 /* Compute the DMT. */
8897 unsigned char *contents
= NULL
;
8899 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
8900 for (pass
= 0; pass
< 2; pass
++)
8902 unsigned int off
= 0;
8904 /* For each object file (ie for each module). */
8905 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8908 struct vms_dmt_header
*dmth
= NULL
;
8909 unsigned int psect_count
;
8911 /* Skip this module if it has no DST. */
8912 sub_dst
= PRIV2 (sub
, dst_section
);
8913 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
8918 /* Write the header. */
8919 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
8920 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
8921 bfd_putl32 (sub_dst
->size
, dmth
->size
);
8924 off
+= sizeof (struct vms_dmt_header
);
8927 /* For each section (ie for each psect). */
8928 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8930 /* Only consider interesting sections. */
8931 if (!(o
->flags
& SEC_ALLOC
))
8933 if (o
->flags
& SEC_LINKER_CREATED
)
8938 /* Write an entry. */
8939 struct vms_dmt_psect
*dmtp
;
8941 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
8942 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
8944 bfd_putl32 (o
->size
, dmtp
->length
);
8947 off
+= sizeof (struct vms_dmt_psect
);
8950 bfd_putl32 (psect_count
, dmth
->psect_count
);
8955 contents
= bfd_zalloc (info
->output_bfd
, off
);
8956 if (contents
== NULL
)
8958 dmt
->contents
= contents
;
8963 BFD_ASSERT (off
== dmt
->size
);
8971 /* Read the contents of a section.
8972 buf points to a buffer of buf_size bytes to be filled with
8973 section data (starting at offset into section) */
8976 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
8977 void *buf
, file_ptr offset
,
8978 bfd_size_type count
)
8982 /* Image are easy. */
8983 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8984 return _bfd_generic_get_section_contents (abfd
, section
,
8985 buf
, offset
, count
);
8988 if (offset
+ count
< count
8989 || offset
+ count
> section
->size
)
8991 bfd_set_error (bfd_error_invalid_operation
);
8995 /* If the section is already in memory, just copy it. */
8996 if (section
->flags
& SEC_IN_MEMORY
)
8998 BFD_ASSERT (section
->contents
!= NULL
);
8999 memcpy (buf
, section
->contents
+ offset
, count
);
9002 if (section
->size
== 0)
9005 /* Alloc in memory and read ETIRs. */
9006 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9008 BFD_ASSERT (sec
->contents
== NULL
);
9010 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
9012 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
9013 if (sec
->contents
== NULL
)
9017 if (!alpha_vms_read_sections_content (abfd
, NULL
))
9019 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
9021 sec
->flags
|= SEC_IN_MEMORY
;
9022 memcpy (buf
, section
->contents
+ offset
, count
);
9027 /* Set the format of a file being written. */
9030 alpha_vms_mkobject (bfd
* abfd
)
9032 const bfd_arch_info_type
*arch
;
9034 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
9036 if (!vms_initialize (abfd
))
9039 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
9040 if (PRIV (recwr
.buf
) == NULL
)
9043 arch
= bfd_scan_arch ("alpha");
9047 bfd_set_error (bfd_error_wrong_format
);
9051 abfd
->arch_info
= arch
;
9058 /* Called when the BFD is being closed to do any necessary cleanup. */
9061 vms_close_and_cleanup (bfd
* abfd
)
9063 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
9065 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
9068 if (abfd
->format
== bfd_archive
)
9070 bfd_release (abfd
, abfd
->tdata
.any
);
9071 abfd
->tdata
.any
= NULL
;
9075 if (PRIV (recrd
.buf
) != NULL
)
9076 free (PRIV (recrd
.buf
));
9078 if (PRIV (sections
) != NULL
)
9079 free (PRIV (sections
));
9081 bfd_release (abfd
, abfd
->tdata
.any
);
9082 abfd
->tdata
.any
= NULL
;
9085 if (abfd
->direction
== write_direction
)
9087 /* Last step on VMS is to convert the file to variable record length
9089 if (bfd_cache_close (abfd
) != TRUE
)
9091 if (_bfd_vms_convert_to_var_unix_filename (abfd
->filename
) != TRUE
)
9099 /* Called when a new section is created. */
9102 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9106 vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n",
9107 abfd
, section
->index
, section
->name
));
9109 bfd_set_section_alignment (abfd
, section
, 0);
9111 vms_debug2 ((7, "%d: %s\n", section
->index
, section
->name
));
9113 amt
= sizeof (struct vms_section_data_struct
);
9114 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9115 if (section
->used_by_bfd
== NULL
)
9118 /* Create the section symbol. */
9119 return _bfd_generic_new_section_hook (abfd
, section
);
9122 /* Part 4.5, symbols. */
9124 /* Print symbol to file according to how. how is one of
9125 bfd_print_symbol_name just print the name
9126 bfd_print_symbol_more print more (???)
9127 bfd_print_symbol_all print all we know, which is not much right now :-). */
9130 vms_print_symbol (bfd
* abfd
,
9133 bfd_print_symbol_type how
)
9135 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9136 abfd
, file
, symbol
, how
));
9140 case bfd_print_symbol_name
:
9141 case bfd_print_symbol_more
:
9142 fprintf ((FILE *)file
," %s", symbol
->name
);
9145 case bfd_print_symbol_all
:
9147 const char *section_name
= symbol
->section
->name
;
9149 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9151 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9157 /* Return information about symbol in ret.
9159 fill type, value and name
9162 B bss segment symbol
9164 D data segment symbol
9166 t a static function symbol
9167 T text segment symbol
9172 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9178 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9180 sec
= symbol
->section
;
9187 else if (bfd_is_com_section (sec
))
9189 else if (bfd_is_abs_section (sec
))
9191 else if (bfd_is_und_section (sec
))
9193 else if (bfd_is_ind_section (sec
))
9195 else if ((symbol
->flags
& BSF_FUNCTION
)
9196 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9198 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9200 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9205 if (ret
->type
!= 'U')
9206 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9209 ret
->name
= symbol
->name
;
9212 /* Return TRUE if the given symbol sym in the BFD abfd is
9213 a compiler generated local label, else return FALSE. */
9216 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9219 vms_debug2 ((1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd
, name
));
9220 return name
[0] == '$';
9223 /* Part 4.7, writing an object file. */
9225 /* Sets the contents of the section section in BFD abfd to the data starting
9226 in memory at LOCATION. The data is written to the output section starting
9227 at offset offset for count bytes.
9229 Normally TRUE is returned, else FALSE. Possible error returns are:
9230 o bfd_error_no_contents - The output section does not have the
9231 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9232 o and some more too */
9235 _bfd_vms_set_section_contents (bfd
* abfd
,
9237 const void * location
,
9239 bfd_size_type count
)
9241 if (section
->contents
== NULL
)
9243 section
->contents
= bfd_alloc (abfd
, section
->size
);
9244 if (section
->contents
== NULL
)
9247 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9253 /* Set the architecture and machine type in BFD abfd to arch and mach.
9254 Find the correct pointer to a structure and insert it into the arch_info
9258 alpha_vms_set_arch_mach (bfd
*abfd
,
9259 enum bfd_architecture arch
, unsigned long mach
)
9261 if (arch
!= bfd_arch_alpha
9262 && arch
!= bfd_arch_unknown
)
9265 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9268 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9271 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9272 asection
*sec
, flagword no_flags
, flagword flags
)
9274 vms_section_data (sec
)->no_flags
= no_flags
;
9275 vms_section_data (sec
)->flags
= flags
;
9278 struct vms_private_data_struct
*
9279 bfd_vms_get_data (bfd
*abfd
)
9281 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9284 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9285 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9286 #define vms_bfd_copy_link_hash_symbol_type \
9287 _bfd_generic_copy_link_hash_symbol_type
9288 #define vms_bfd_is_group_section bfd_generic_is_group_section
9289 #define vms_bfd_discard_group bfd_generic_discard_group
9290 #define vms_section_already_linked _bfd_generic_section_already_linked
9291 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9292 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9294 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9295 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9296 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9297 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9298 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9299 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9301 /* Symbols table. */
9302 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9303 #define alpha_vms_bfd_is_target_special_symbol \
9304 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9305 #define alpha_vms_print_symbol vms_print_symbol
9306 #define alpha_vms_get_symbol_info vms_get_symbol_info
9307 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9308 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9309 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9310 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9311 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9312 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_dst_line
9313 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9315 /* Generic table. */
9316 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9317 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9318 #define alpha_vms_new_section_hook vms_new_section_hook
9319 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9320 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9322 #define alpha_vms_bfd_get_relocated_section_contents \
9323 bfd_generic_get_relocated_section_contents
9325 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9326 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9327 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9328 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9329 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9330 #define alpha_vms_section_already_linked \
9331 _bfd_generic_section_already_linked
9333 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9334 #define alpha_vms_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
9335 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9336 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9337 _bfd_generic_copy_link_hash_symbol_type
9339 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9341 #define alpha_vms_get_dynamic_symtab_upper_bound \
9342 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9343 #define alpha_vms_canonicalize_dynamic_symtab \
9344 _bfd_nodynamic_canonicalize_dynamic_symtab
9345 #define alpha_vms_get_dynamic_reloc_upper_bound \
9346 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9347 #define alpha_vms_canonicalize_dynamic_reloc \
9348 _bfd_nodynamic_canonicalize_dynamic_reloc
9350 const bfd_target vms_alpha_vec
=
9352 "vms-alpha", /* Name. */
9353 bfd_target_evax_flavour
,
9354 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9355 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9357 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9358 | WP_TEXT
| D_PAGED
), /* Object flags. */
9359 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9360 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9361 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9362 0, /* symbol_leading_char. */
9363 ' ', /* ar_pad_char. */
9364 15, /* ar_max_namelen. */
9365 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9366 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9367 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9368 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9369 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9370 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9372 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9373 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9374 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9375 _bfd_vms_lib_alpha_mkarchive
, bfd_false
},
9376 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9377 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9379 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9380 BFD_JUMP_TABLE_COPY (vms
),
9381 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9382 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9383 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9384 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9385 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9386 BFD_JUMP_TABLE_LINK (alpha_vms
),
9387 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),