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 asection
*dst_section
;
309 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva
; /* relative virtual address of symbol vector */
315 unsigned char matchctl
;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index
;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map
*eisd_head
;
325 struct vms_internal_eisd_map
*eisd_tail
;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map
*gbl_eisd_head
;
329 struct vms_internal_eisd_map
*gbl_eisd_tail
;
331 /* linkage index counter used by conditional store commands */
332 int vms_linkage_index
;
334 /* see tc-alpha.c of gas for a description. */
335 int flag_hash_long_names
; /* -+, hash instead of truncate */
336 int flag_show_after_trunc
; /* -H, show hashing/truncation */
339 #define PRIV2(abfd, name) \
340 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
341 #define PRIV(name) PRIV2(abfd,name)
344 /* Used to keep extra VMS specific information for a given section.
346 reloc_size holds the size of the relocation stream, note this
347 is very different from the number of relocations as VMS relocations
350 reloc_stream is the actual stream of relocation entries. */
352 struct vms_section_data_struct
354 /* Maximnum number of entries in sec->relocation. */
357 /* Corresponding eisd. Used only while generating executables. */
358 struct vms_internal_eisd_map
*eisd
;
360 /* PSC flags to be clear. */
363 /* PSC flags to be set. */
367 #define vms_section_data(sec) \
368 ((struct vms_section_data_struct *)sec->used_by_bfd)
370 /* To be called from the debugger. */
371 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*abfd
);
373 static int vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
);
374 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
375 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
376 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
377 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
379 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*info
);
380 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*info
);
381 static void alpha_vms_add_lw_fixup (struct bfd_link_info
*, unsigned int,
391 /* Number of elements in VEC. */
393 #define VEC_COUNT(VEC) ((VEC).nbr_el)
395 /* Get the address of the Nth element. */
397 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
399 #define VEC_INIT(VEC) \
406 /* Be sure there is room for a new element. */
408 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
410 /* Allocate room for a new element and return its address. */
412 #define VEC_APPEND(VEC, TYPE) \
413 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
415 /* Append an element. */
417 #define VEC_APPEND_EL(VEC, TYPE, EL) \
418 (*(VEC_APPEND (VEC, TYPE)) = EL)
420 struct alpha_vms_vma_ref
422 bfd_vma vma
; /* Vma in the output. */
423 bfd_vma ref
; /* Reference in the input. */
426 struct alpha_vms_shlib_el
429 bfd_boolean has_fixups
;
431 struct vector_type lp
; /* Vector of bfd_vma. */
432 struct vector_type ca
; /* Vector of bfd_vma. */
433 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
436 /* Alpha VMS linker hash table. */
438 struct alpha_vms_link_hash_table
440 struct bfd_link_hash_table root
;
442 /* Vector of shared libaries. */
443 struct vector_type shrlibs
;
448 /* Base address. Used by fixups. */
452 #define alpha_vms_link_hash(INFO) \
453 ((struct alpha_vms_link_hash_table *)(INFO->hash))
455 /* Alpha VMS linker hash table entry. */
457 struct alpha_vms_link_hash_entry
459 struct bfd_link_hash_entry root
;
461 /* Pointer to the original vms symbol. */
462 struct vms_symbol_entry
*sym
;
467 /* Read & process EIHD record.
468 Return TRUE on success, FALSE on error. */
471 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
472 unsigned int *eihs_offset
)
474 unsigned int imgtype
, size
;
476 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
478 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
480 size
= bfd_getl32 (eihd
->size
);
481 imgtype
= bfd_getl32 (eihd
->imgtype
);
483 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
484 abfd
->flags
|= EXEC_P
;
486 symvva
= bfd_getl64 (eihd
->symvva
);
489 PRIV (symvva
) = symvva
;
490 abfd
->flags
|= DYNAMIC
;
493 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
494 PRIV (matchctl
) = eihd
->matchctl
;
496 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
497 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
499 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
500 size
, imgtype
, (unsigned long)symvva
,
501 *eisd_offset
, *eihs_offset
));
506 /* Read & process EISD record.
507 Return TRUE on success, FALSE on error. */
510 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
512 int section_count
= 0;
514 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
518 struct vms_eisd
*eisd
;
519 unsigned int rec_size
;
521 unsigned long long vaddr
;
528 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
529 rec_size
= bfd_getl32 (eisd
->eisdsize
);
534 /* Skip to next block if pad. */
535 if (rec_size
== 0xffffffff)
537 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
543 size
= bfd_getl32 (eisd
->secsize
);
544 vaddr
= bfd_getl64 (eisd
->virt_addr
);
545 flags
= bfd_getl32 (eisd
->flags
);
546 vbn
= bfd_getl32 (eisd
->vbn
);
548 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
549 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
551 /* VMS combines psects from .obj files into isects in the .exe. This
552 process doesn't preserve enough information to reliably determine
553 what's in each section without examining the data. This is
554 especially true of DWARF debug sections. */
555 bfd_flags
= SEC_ALLOC
;
557 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
559 if (flags
& EISD__M_EXE
)
560 bfd_flags
|= SEC_CODE
;
562 if (flags
& EISD__M_NONSHRADR
)
563 bfd_flags
|= SEC_DATA
;
565 if (!(flags
& EISD__M_WRT
))
566 bfd_flags
|= SEC_READONLY
;
568 if (flags
& EISD__M_DZRO
)
569 bfd_flags
|= SEC_DATA
;
571 if (flags
& EISD__M_FIXUPVEC
)
572 bfd_flags
|= SEC_DATA
;
574 if (flags
& EISD__M_CRF
)
575 bfd_flags
|= SEC_DATA
;
577 if (flags
& EISD__M_GBL
)
579 name
= _bfd_vms_save_counted_string (eisd
->gblnam
);
580 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
581 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
583 else if (flags
& EISD__M_FIXUPVEC
)
585 else if (eisd
->type
== EISD__K_USRSTACK
)
591 name
= (char*) bfd_alloc (abfd
, 32);
592 if (flags
& EISD__M_DZRO
)
594 else if (flags
& EISD__M_EXE
)
596 else if (!(flags
& EISD__M_WRT
))
600 BFD_ASSERT (section_count
< 999);
601 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
604 section
= bfd_make_section (abfd
, name
);
609 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
610 section
->size
= size
;
611 section
->vma
= vaddr
;
613 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
620 /* Read & process EIHS record.
621 Return TRUE on success, FALSE on error. */
624 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
626 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
627 unsigned int gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
628 unsigned int gstsize ATTRIBUTE_UNUSED
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
629 unsigned int dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
630 unsigned int dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
631 unsigned int dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
632 unsigned int dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
636 vms_debug (8, "_bfd_vms_slurp_ihs\n");
637 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
638 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
643 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
645 section
= bfd_make_section (abfd
, "$DST$");
649 section
->size
= dstsize
;
650 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
652 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
655 PRIV (dst_section
) = section
;
656 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
661 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
663 section
= bfd_make_section (abfd
, "$DMT$");
667 section
->size
= dmtbytes
;
668 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
670 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
676 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
678 bfd_set_error (bfd_error_file_truncated
);
682 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
685 abfd
->flags
|= HAS_SYMS
;
691 /* Object file reading. */
693 /* Object file input functions. */
695 /* Get next record from object file to vms_buf.
696 Set PRIV(buf_size) and return it
698 This is a little tricky since it should be portable.
700 The openVMS object file has 'variable length' which means that
701 read() returns data in chunks of (hopefully) correct and expected
702 size. The linker (and other tools on VMS) depend on that. Unix
703 doesn't know about 'formatted' files, so reading and writing such
704 an object file in a Unix environment is not trivial.
706 With the tool 'file' (available on all VMS FTP sites), one
707 can view and change the attributes of a file. Changing from
708 'variable length' to 'fixed length, 512 bytes' reveals the
709 record size at the first 2 bytes of every record. The same
710 may happen during the transfer of object files from VMS to Unix,
711 at least with UCX, the DEC implementation of TCP/IP.
713 The VMS format repeats the size at bytes 2 & 3 of every record.
715 On the first call (file_format == FF_UNKNOWN) we check if
716 the first and the third byte pair (!) of the record match.
717 If they do it's an object file in an Unix environment or with
718 wrong attributes (FF_FOREIGN), else we should be in a VMS
719 environment where read() returns the record size (FF_NATIVE).
721 Reading is always done in 2 steps:
722 1. first just the record header is read and the size extracted,
723 2. then the read buffer is adjusted and the remaining bytes are
726 All file I/O is done on even file positions. */
728 #define VMS_OBJECT_ADJUSTMENT 2
731 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
733 /* Set the file format once for all on the first invocation. */
734 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
736 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
737 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
738 PRIV (recrd
.file_format
) = FF_FOREIGN
;
740 PRIV (recrd
.file_format
) = FF_NATIVE
;
743 /* The adjustment is needed only in an Unix environment. */
744 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
745 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
748 /* Implement step #1 of the object record reading procedure.
749 Return the record type or -1 on failure. */
752 _bfd_vms_get_object_record (bfd
*abfd
)
754 unsigned int test_len
= 6;
757 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
759 /* Skip alignment byte if the current position is odd. */
760 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
762 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
764 bfd_set_error (bfd_error_file_truncated
);
769 /* Read the record header */
770 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
772 bfd_set_error (bfd_error_file_truncated
);
776 /* Reset the record pointer. */
777 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
778 maybe_adjust_record_pointer_for_object (abfd
);
780 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
783 type
= bfd_getl16 (PRIV (recrd
.rec
));
785 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
786 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
791 /* Implement step #2 of the object record reading procedure.
792 Return the size of the record or 0 on failure. */
795 vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
)
797 unsigned int to_read
;
799 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
801 /* Extract record size. */
802 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
804 if (PRIV (recrd
.rec_size
) <= 0)
806 bfd_set_error (bfd_error_file_truncated
);
810 /* That's what the linker manual says. */
811 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
813 bfd_set_error (bfd_error_file_truncated
);
817 /* Take into account object adjustment. */
818 to_read
= PRIV (recrd
.rec_size
);
819 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
820 to_read
+= VMS_OBJECT_ADJUSTMENT
;
822 /* Adjust the buffer. */
823 if (to_read
> PRIV (recrd
.buf_size
))
826 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
827 if (PRIV (recrd
.buf
) == NULL
)
829 PRIV (recrd
.buf_size
) = to_read
;
832 /* Read the remaining record. */
833 to_read
-= read_so_far
;
835 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
837 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
839 bfd_set_error (bfd_error_file_truncated
);
843 /* Reset the record pointer. */
844 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
845 maybe_adjust_record_pointer_for_object (abfd
);
847 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
848 PRIV (recrd
.rec_size
)));
850 return PRIV (recrd
.rec_size
);
853 /* Read and process emh record.
854 Return TRUE on success, FALSE on error. */
857 _bfd_vms_slurp_ehdr (bfd
*abfd
)
860 unsigned char *vms_rec
;
863 vms_rec
= PRIV (recrd
.rec
);
865 vms_debug2 ((2, "HDR/EMH\n"));
867 subtype
= bfd_getl16 (vms_rec
+ 4);
869 vms_debug2 ((3, "subtype %d\n", subtype
));
875 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
876 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
877 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
878 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
879 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20);
880 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
881 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
);
883 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
887 PRIV (hdr_data
).hdr_c_lnm
=
888 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
892 PRIV (hdr_data
).hdr_c_src
=
893 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
897 PRIV (hdr_data
).hdr_c_ttl
=
898 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
907 bfd_set_error (bfd_error_wrong_format
);
914 /* Typical sections for evax object files. */
916 #define EVAX_ABS_NAME "$ABS$"
917 #define EVAX_CODE_NAME "$CODE$"
918 #define EVAX_LINK_NAME "$LINK$"
919 #define EVAX_DATA_NAME "$DATA$"
920 #define EVAX_BSS_NAME "$BSS$"
921 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
922 #define EVAX_READONLY_NAME "$READONLY$"
923 #define EVAX_LITERAL_NAME "$LITERAL$"
924 #define EVAX_LITERALS_NAME "$LITERALS"
925 #define EVAX_COMMON_NAME "$COMMON$"
926 #define EVAX_LOCAL_NAME "$LOCAL$"
928 struct sec_flags_struct
930 const char *name
; /* Name of section. */
932 flagword flags_always
; /* Flags we set always. */
934 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
937 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
939 static const struct sec_flags_struct evax_section_flags
[] =
945 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
947 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
),
949 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
),
950 (SEC_CODE
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
952 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
),
953 (SEC_DATA
| SEC_READONLY
),
954 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
),
955 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
957 (EGPS__V_REL
| EGPS__V_RD
),
958 (SEC_DATA
| SEC_READONLY
),
959 (EGPS__V_REL
| EGPS__V_RD
),
960 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
962 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
964 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
965 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
967 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
969 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
971 { EVAX_READONLYADDR_NAME
,
972 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
),
973 (SEC_DATA
| SEC_READONLY
),
974 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
),
975 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
976 { EVAX_READONLY_NAME
,
977 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
),
978 (SEC_DATA
| SEC_READONLY
),
979 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
),
980 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
982 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
984 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
985 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
986 { EVAX_LITERALS_NAME
,
987 (EGPS__V_PIC
| EGPS__V_OVR
),
988 (SEC_DATA
| SEC_READONLY
),
989 (EGPS__V_PIC
| EGPS__V_OVR
),
990 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
992 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
994 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
995 (SEC_IN_MEMORY
| SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) }
998 /* Retrieve BFD section flags by name and size. */
1001 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1007 while (section_flags
[i
].name
!= NULL
)
1009 if (strcmp (name
, section_flags
[i
].name
) == 0)
1012 return section_flags
[i
].flags_hassize
;
1014 return section_flags
[i
].flags_always
;
1019 return section_flags
[i
].flags_hassize
;
1020 return section_flags
[i
].flags_always
;
1023 /* Retrieve VMS section flags by name and size. */
1026 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1032 while (section_flags
[i
].name
!= NULL
)
1034 if (strcmp (name
, section_flags
[i
].name
) == 0)
1037 return section_flags
[i
].vflags_hassize
;
1039 return section_flags
[i
].vflags_always
;
1044 return section_flags
[i
].vflags_hassize
;
1045 return section_flags
[i
].vflags_always
;
1048 /* Add SYM to the symbol table of ABFD.
1049 Return FALSE in case of error. */
1052 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1054 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1056 if (PRIV (max_sym_count
) == 0)
1058 PRIV (max_sym_count
) = 128;
1059 PRIV (syms
) = bfd_malloc
1060 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1064 PRIV (max_sym_count
) *= 2;
1065 PRIV (syms
) = bfd_realloc
1067 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1069 if (PRIV (syms
) == NULL
)
1073 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1077 /* Create a symbol whose name is ASCIC and add it to ABFD.
1078 Return NULL in case of error. */
1080 static struct vms_symbol_entry
*
1081 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1083 struct vms_symbol_entry
*entry
;
1087 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1090 entry
->namelen
= len
;
1091 memcpy (entry
->name
, ascic
, len
);
1092 entry
->name
[len
] = 0;
1093 entry
->owner
= abfd
;
1095 if (!add_symbol_entry (abfd
, entry
))
1100 /* Read and process EGSD. Return FALSE on failure. */
1103 _bfd_vms_slurp_egsd (bfd
*abfd
)
1105 int gsd_type
, gsd_size
;
1107 unsigned char *vms_rec
;
1108 flagword new_flags
, old_flags
;
1110 unsigned long base_addr
;
1111 unsigned long align_addr
;
1113 vms_debug2 ((2, "EGSD\n"));
1115 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1116 PRIV (recrd
.rec_size
) -= 8;
1118 /* Calculate base address for each section. */
1121 while (PRIV (recrd
.rec_size
) > 0)
1123 vms_rec
= PRIV (recrd
.rec
);
1125 gsd_type
= bfd_getl16 (vms_rec
);
1126 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1128 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1134 /* Program section definition. */
1135 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1137 name
= _bfd_vms_save_counted_string (&egps
->namlng
);
1138 section
= bfd_make_section (abfd
, name
);
1142 old_flags
= bfd_getl16 (egps
->flags
);
1143 vms_section_data (section
)->flags
= old_flags
;
1144 vms_section_data (section
)->no_flags
= 0;
1145 section
->size
= bfd_getl32 (egps
->alloc
);
1146 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1148 if (!(old_flags
& EGPS__V_NOMOD
))
1150 new_flags
|= SEC_HAS_CONTENTS
;
1151 if (old_flags
& EGPS__V_REL
)
1152 new_flags
|= SEC_RELOC
;
1154 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1156 section
->alignment_power
= egps
->align
;
1157 if ((old_flags
& EGPS__V_REL
) != 0)
1159 /* Give a non-overlapping vma to non absolute sections. */
1160 align_addr
= (1 << section
->alignment_power
);
1161 if ((base_addr
% align_addr
) != 0)
1162 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1163 section
->vma
= (bfd_vma
)base_addr
;
1164 base_addr
+= section
->size
;
1168 section
->filepos
= 0;
1170 /* Append it to the section array. */
1171 if (PRIV (section_count
) >= PRIV (section_max
))
1173 if (PRIV (section_max
) == 0)
1174 PRIV (section_max
) = 16;
1176 PRIV (section_max
) *= 2;
1177 PRIV (sections
) = bfd_realloc_or_free
1178 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1179 if (PRIV (sections
) == NULL
)
1183 PRIV (sections
)[PRIV (section_count
)] = section
;
1184 PRIV (section_count
)++;
1187 vms_debug (4, "EGSD P-section %d (%s, flags %04x) ",
1188 section
->index
, name
, old_flags
);
1189 vms_debug (4, "%lu bytes at 0x%08lx (mem %p)\n",
1190 (unsigned long)section
->size
,
1191 (unsigned long)section
->vma
, section
->contents
);
1199 struct vms_symbol_entry
*entry
;
1200 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1202 old_flags
= bfd_getl16 (egsy
->flags
);
1203 if (old_flags
& EGSY__V_DEF
)
1204 nameoff
= ESDF__B_NAMLNG
;
1206 nameoff
= ESRF__B_NAMLNG
;
1208 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1212 /* Allow only duplicate reference. */
1213 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1216 if (entry
->typ
== 0)
1218 entry
->typ
= gsd_type
;
1219 entry
->data_type
= egsy
->datyp
;
1220 entry
->flags
= old_flags
;
1223 if (old_flags
& EGSY__V_DEF
)
1225 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1227 entry
->value
= bfd_getl64 (esdf
->value
);
1228 entry
->section
= PRIV (sections
)[bfd_getl32 (esdf
->psindx
)];
1230 if (old_flags
& EGSY__V_NORM
)
1232 PRIV (norm_sym_count
)++;
1234 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1235 entry
->code_section
=
1236 PRIV (sections
)[bfd_getl32 (esdf
->ca_psindx
)];
1245 struct vms_symbol_entry
*entry
;
1246 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1248 old_flags
= bfd_getl16 (egst
->header
.flags
);
1249 if (old_flags
& EGSY__V_DEF
)
1250 nameoff
= ESDF__B_NAMLNG
;
1252 nameoff
= ESRF__B_NAMLNG
;
1254 entry
= add_symbol (abfd
, &egst
->namlng
);
1259 entry
->typ
= gsd_type
;
1260 entry
->data_type
= egst
->header
.datyp
;
1261 entry
->flags
= old_flags
;
1263 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1265 if (old_flags
& EGSY__V_REL
)
1266 entry
->section
= PRIV (sections
)[bfd_getl32 (egst
->psindx
)];
1268 entry
->section
= bfd_abs_section_ptr
;
1270 entry
->value
= bfd_getl64 (egst
->lp_2
);
1272 if (old_flags
& EGSY__V_NORM
)
1274 PRIV (norm_sym_count
)++;
1276 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1277 entry
->code_section
= bfd_abs_section_ptr
;
1284 /* Currently ignored. */
1289 (*_bfd_error_handler
) (_("Unknown EGSD subtype %d"), gsd_type
);
1290 bfd_set_error (bfd_error_bad_value
);
1294 PRIV (recrd
.rec_size
) -= gsd_size
;
1295 PRIV (recrd
.rec
) += gsd_size
;
1298 if (PRIV (gsd_sym_count
) > 0)
1299 abfd
->flags
|= HAS_SYMS
;
1304 /* Stack routines for vms ETIR commands. */
1306 /* Push value and section index. */
1309 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1311 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1312 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1314 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1315 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1317 if (PRIV (stackptr
) >= STACKSIZE
)
1319 bfd_set_error (bfd_error_bad_value
);
1320 (*_bfd_error_handler
) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1325 /* Pop value and section index. */
1328 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1330 if (PRIV (stackptr
) == 0)
1332 bfd_set_error (bfd_error_bad_value
);
1333 (*_bfd_error_handler
) (_("Stack underflow in _bfd_vms_pop"));
1337 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1338 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1340 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1343 /* Routines to fill sections contents during tir/etir read. */
1345 /* Initialize image buffer pointer to be filled. */
1348 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1352 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1354 sec
= PRIV (sections
)[sect
];
1358 /* Reading contents to an output bfd. */
1360 if (sec
->output_section
== NULL
)
1362 /* Section discarded. */
1363 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1365 /* This is not used. */
1366 PRIV (image_section
) = NULL
;
1367 PRIV (image_offset
) = 0;
1370 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1371 PRIV (image_section
) = sec
->output_section
;
1375 PRIV (image_offset
) = vma
;
1376 PRIV (image_section
) = sec
;
1380 /* Increment image buffer pointer by offset. */
1383 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1385 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1387 PRIV (image_offset
) += offset
;
1390 /* Save current DST location counter under specified index. */
1393 dst_define_location (bfd
*abfd
, unsigned int loc
)
1395 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1397 /* Grow the ptr offset table if necessary. */
1398 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1400 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1401 (loc
+ 1) * sizeof (unsigned int));
1402 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1405 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1408 /* Restore saved DST location counter from specified index. */
1411 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1413 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1415 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1418 /* Retrieve saved DST location counter from specified index. */
1421 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1423 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1425 return PRIV (dst_ptr_offsets
)[loc
];
1428 /* Write multiple bytes to section image. */
1431 image_write (bfd
*abfd
, unsigned char *ptr
, int size
)
1434 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1435 (long)PRIV (image_offset
));
1436 _bfd_hexdump (9, ptr
, size
, 0);
1439 if (PRIV (image_section
)->contents
!= NULL
)
1441 asection
*sec
= PRIV (image_section
);
1442 file_ptr off
= PRIV (image_offset
);
1445 if (off
> (file_ptr
)sec
->size
1446 || size
> (file_ptr
)sec
->size
1447 || off
+ size
> (file_ptr
)sec
->size
)
1449 bfd_set_error (bfd_error_bad_value
);
1453 memcpy (sec
->contents
+ off
, ptr
, size
);
1456 PRIV (image_offset
) += size
;
1460 /* Write byte to section image. */
1463 image_write_b (bfd
* abfd
, unsigned int value
)
1465 unsigned char data
[1];
1467 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1471 return image_write (abfd
, data
, sizeof (data
));
1474 /* Write 2-byte word to image. */
1477 image_write_w (bfd
* abfd
, unsigned int value
)
1479 unsigned char data
[2];
1481 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1483 bfd_putl16 (value
, data
);
1484 return image_write (abfd
, data
, sizeof (data
));
1487 /* Write 4-byte long to image. */
1490 image_write_l (bfd
* abfd
, unsigned long value
)
1492 unsigned char data
[4];
1494 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1496 bfd_putl32 (value
, data
);
1497 return image_write (abfd
, data
, sizeof (data
));
1500 /* Write 8-byte quad to image. */
1503 image_write_q (bfd
* abfd
, bfd_vma value
)
1505 unsigned char data
[8];
1507 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1509 bfd_putl64 (value
, data
);
1510 return image_write (abfd
, data
, sizeof (data
));
1514 _bfd_vms_etir_name (int cmd
)
1518 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1519 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1520 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1521 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1522 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1523 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1524 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1525 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1526 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1527 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1528 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1529 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1530 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1531 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1532 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1533 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1534 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1535 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1536 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1537 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1538 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1539 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1540 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1541 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1542 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1543 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1544 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1545 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1546 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1547 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1548 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1549 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1550 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1551 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1552 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1553 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1554 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1555 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1556 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1557 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1558 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1559 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1560 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1561 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1562 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1563 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1564 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1565 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1566 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1569 /* These names have not yet been added to this switch statement. */
1570 (*_bfd_error_handler
) (_("unknown ETIR command %d"), cmd
);
1575 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1578 _bfd_vms_get_value (bfd
*abfd
, const unsigned char *ascic
,
1579 struct bfd_link_info
*info
,
1581 struct alpha_vms_link_hash_entry
**hp
)
1586 struct alpha_vms_link_hash_entry
*h
;
1588 /* Not linking. Do not try to resolve the symbol. */
1597 for (i
= 0; i
< len
; i
++)
1598 name
[i
] = ascic
[i
+ 1];
1601 h
= (struct alpha_vms_link_hash_entry
*)
1602 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1607 && (h
->root
.type
== bfd_link_hash_defined
1608 || h
->root
.type
== bfd_link_hash_defweak
))
1609 *vma
= h
->root
.u
.def
.value
1610 + h
->root
.u
.def
.section
->output_offset
1611 + h
->root
.u
.def
.section
->output_section
->vma
;
1612 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1616 if (!(*info
->callbacks
->undefined_symbol
)
1617 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
))
1625 #define RELC_SHR_BASE 0x10000
1626 #define RELC_SEC_BASE 0x20000
1627 #define RELC_MASK 0x0ffff
1630 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1632 /* Handle undefined symbols. */
1633 if (h
== NULL
|| h
->sym
== NULL
)
1636 if (h
->sym
->typ
== EGSD__C_SYMG
)
1638 if (h
->sym
->flags
& EGSY__V_REL
)
1639 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1642 /* Can this happen (non-relocatable symg) ? I'd like to see
1647 if (h
->sym
->typ
== EGSD__C_SYM
)
1649 if (h
->sym
->flags
& EGSY__V_REL
)
1658 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1660 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1664 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1665 unsigned int rel
, bfd_vma vma
)
1667 asection
*sec
= PRIV (sections
)[rel
& RELC_MASK
];
1671 if (sec
->output_section
== NULL
)
1673 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1676 return vma
+ sec
->vma
;
1679 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1680 the output section (used during linking).
1681 Return FALSE in case of error. */
1684 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1687 unsigned int length
;
1688 unsigned char *maxptr
;
1693 struct alpha_vms_link_hash_entry
*h
;
1695 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1696 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1698 ptr
= PRIV (recrd
.rec
);
1699 length
= PRIV (recrd
.rec_size
);
1700 maxptr
= ptr
+ length
;
1702 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1704 while (ptr
< maxptr
)
1706 int cmd
= bfd_getl16 (ptr
);
1707 int cmd_length
= bfd_getl16 (ptr
+ 2);
1712 _bfd_vms_debug (4, "etir: %s(%d)\n",
1713 _bfd_vms_etir_name (cmd
), cmd
);
1714 _bfd_hexdump (8, ptr
, cmd_length
- 4, (long) ptr
);
1722 stack 32 bit value of symbol (high bits set to 0). */
1723 case ETIR__C_STA_GBL
:
1724 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1725 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1731 stack 32 bit value, sign extend to 64 bit. */
1732 case ETIR__C_STA_LW
:
1733 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1739 stack 64 bit value of symbol. */
1740 case ETIR__C_STA_QW
:
1741 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1744 /* Stack psect base plus quadword offset
1745 arg: lw section index
1746 qw signed quadword offset (low 32 bits)
1748 Stack qw argument and section index
1749 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1750 case ETIR__C_STA_PQ
:
1754 psect
= bfd_getl32 (ptr
);
1755 if ((unsigned int) psect
>= PRIV (section_count
))
1757 (*_bfd_error_handler
) (_("bad section index in %s"),
1758 _bfd_vms_etir_name (cmd
));
1759 bfd_set_error (bfd_error_bad_value
);
1762 op1
= bfd_getl64 (ptr
+ 4);
1763 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1767 case ETIR__C_STA_LI
:
1768 case ETIR__C_STA_MOD
:
1769 case ETIR__C_STA_CKARG
:
1770 (*_bfd_error_handler
) (_("unsupported STA cmd %s"),
1771 _bfd_vms_etir_name (cmd
));
1775 /* Store byte: pop stack, write byte
1778 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1779 if (rel1
!= RELC_NONE
)
1781 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1784 /* Store word: pop stack, write word
1787 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1788 if (rel1
!= RELC_NONE
)
1790 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1793 /* Store longword: pop stack, write longword
1795 case ETIR__C_STO_LW
:
1796 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1797 if (rel1
& RELC_SEC_BASE
)
1799 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1802 else if (rel1
& RELC_SHR_BASE
)
1804 alpha_vms_add_lw_fixup (info
, rel1
& RELC_MASK
, op1
);
1807 if (rel1
!= RELC_NONE
)
1809 if (rel1
!= RELC_REL
)
1811 alpha_vms_add_lw_reloc (info
);
1813 image_write_l (abfd
, op1
);
1816 /* Store quadword: pop stack, write quadword
1818 case ETIR__C_STO_QW
:
1819 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1820 if (rel1
& RELC_SEC_BASE
)
1822 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1825 else if (rel1
& RELC_SHR_BASE
)
1827 if (rel1
!= RELC_NONE
)
1829 if (rel1
!= RELC_REL
)
1831 alpha_vms_add_qw_reloc (info
);
1833 image_write_q (abfd
, op1
);
1836 /* Store immediate repeated: pop stack for repeat count
1839 case ETIR__C_STO_IMMR
:
1843 size
= bfd_getl32 (ptr
);
1844 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1845 if (rel1
!= RELC_NONE
)
1848 image_write (abfd
, ptr
+ 4, size
);
1852 /* Store global: write symbol value
1853 arg: cs global symbol name. */
1854 case ETIR__C_STO_GBL
:
1855 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1858 if (h
->sym
->typ
== EGSD__C_SYMG
)
1860 alpha_vms_add_fixup_qr
1861 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
1866 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
1868 alpha_vms_add_qw_reloc (info
);
1871 image_write_q (abfd
, op1
);
1874 /* Store code address: write address of entry point
1875 arg: cs global symbol name (procedure). */
1876 case ETIR__C_STO_CA
:
1877 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1880 if (h
->sym
->flags
& EGSY__V_NORM
)
1882 /* That's really a procedure. */
1883 if (h
->sym
->typ
== EGSD__C_SYMG
)
1885 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
1886 op1
= h
->sym
->symbol_vector
;
1890 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1891 h
->sym
->code_value
);
1892 alpha_vms_add_qw_reloc (info
);
1897 /* Symbol is not a procedure. */
1901 image_write_q (abfd
, op1
);
1904 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1906 case ETIR__C_STO_OFF
:
1907 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1909 if (!(rel1
& RELC_SEC_BASE
))
1912 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1914 image_write_q (abfd
, op1
);
1918 arg: lw count of bytes
1920 case ETIR__C_STO_IMM
:
1924 size
= bfd_getl32 (ptr
);
1925 image_write (abfd
, ptr
+ 4, size
);
1929 /* This code is 'reserved to digital' according to the openVMS
1930 linker manual, however it is generated by the DEC C compiler
1931 and defined in the include file.
1932 FIXME, since the following is just a guess
1933 store global longword: store 32bit value of symbol
1934 arg: cs symbol name. */
1935 case ETIR__C_STO_GBL_LW
:
1936 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1940 image_write_l (abfd
, op1
);
1943 case ETIR__C_STO_RB
:
1944 case ETIR__C_STO_AB
:
1945 case ETIR__C_STO_LP_PSB
:
1946 (*_bfd_error_handler
) (_("%s: not supported"),
1947 _bfd_vms_etir_name (cmd
));
1950 case ETIR__C_STO_HINT_GBL
:
1951 case ETIR__C_STO_HINT_PS
:
1952 (*_bfd_error_handler
) (_("%s: not implemented"),
1953 _bfd_vms_etir_name (cmd
));
1957 /* 200 Store-conditional Linkage Pair
1959 case ETIR__C_STC_LP
:
1961 /* 202 Store-conditional Address at global address
1965 case ETIR__C_STC_GBL
:
1967 /* 203 Store-conditional Code Address at global address
1969 cs procedure name. */
1970 case ETIR__C_STC_GCA
:
1972 /* 204 Store-conditional Address at psect + offset
1976 case ETIR__C_STC_PS
:
1977 (*_bfd_error_handler
) (_("%s: not supported"),
1978 _bfd_vms_etir_name (cmd
));
1982 /* 201 Store-conditional Linkage Pair with Procedure Signature
1988 case ETIR__C_STC_LP_PSB
:
1989 _bfd_vms_get_value (abfd
, ptr
+ 4, info
, &op1
, &h
);
1992 if (h
->sym
->typ
== EGSD__C_SYMG
)
1994 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
1995 op1
= h
->sym
->symbol_vector
;
2000 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2001 h
->sym
->code_value
);
2002 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2008 /* Undefined symbol. */
2012 image_write_q (abfd
, op1
);
2013 image_write_q (abfd
, op2
);
2016 /* 205 Store-conditional NOP at address of global
2018 case ETIR__C_STC_NOP_GBL
:
2021 /* 207 Store-conditional BSR at global address
2024 case ETIR__C_STC_BSR_GBL
:
2027 /* 209 Store-conditional LDA at global address
2030 case ETIR__C_STC_LDA_GBL
:
2033 /* 211 Store-conditional BSR or Hint at global address
2036 case ETIR__C_STC_BOH_GBL
:
2037 /* Currentl ignored. */
2040 /* 213 Store-conditional NOP,BSR or HINT at global address
2043 case ETIR__C_STC_NBH_GBL
:
2045 /* 206 Store-conditional NOP at pect + offset
2048 case ETIR__C_STC_NOP_PS
:
2050 /* 208 Store-conditional BSR at pect + offset
2053 case ETIR__C_STC_BSR_PS
:
2055 /* 210 Store-conditional LDA at psect + offset
2058 case ETIR__C_STC_LDA_PS
:
2060 /* 212 Store-conditional BSR or Hint at pect + offset
2063 case ETIR__C_STC_BOH_PS
:
2065 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2067 case ETIR__C_STC_NBH_PS
:
2068 (*_bfd_error_handler
) ("%s: not supported",
2069 _bfd_vms_etir_name (cmd
));
2073 /* Det relocation base: pop stack, set image location counter
2075 case ETIR__C_CTL_SETRB
:
2076 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2077 if (!(rel1
& RELC_SEC_BASE
))
2079 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2082 /* Augment relocation base: increment image location counter by offset
2083 arg: lw offset value. */
2084 case ETIR__C_CTL_AUGRB
:
2085 op1
= bfd_getl32 (ptr
);
2086 image_inc_ptr (abfd
, op1
);
2089 /* Define location: pop index, save location counter under index
2091 case ETIR__C_CTL_DFLOC
:
2092 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2093 if (rel1
!= RELC_NONE
)
2095 dst_define_location (abfd
, op1
);
2098 /* Set location: pop index, restore location counter from index
2100 case ETIR__C_CTL_STLOC
:
2101 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2102 if (rel1
!= RELC_NONE
)
2104 dst_restore_location (abfd
, op1
);
2107 /* Stack defined location: pop index, push location counter from index
2109 case ETIR__C_CTL_STKDL
:
2110 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2111 if (rel1
!= RELC_NONE
)
2113 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2116 case ETIR__C_OPR_NOP
: /* No-op. */
2119 case ETIR__C_OPR_ADD
: /* Add. */
2120 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2121 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2122 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2124 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2126 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2129 case ETIR__C_OPR_SUB
: /* Subtract. */
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_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2136 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2137 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2140 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2142 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2145 case ETIR__C_OPR_MUL
: /* Multiply. */
2146 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2147 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2148 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2150 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2153 case ETIR__C_OPR_DIV
: /* Divide. */
2154 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2155 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2156 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2159 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2161 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2164 case ETIR__C_OPR_AND
: /* Logical AND. */
2165 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2166 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2167 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2169 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2172 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2173 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2174 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2175 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2177 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2180 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2181 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2182 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2183 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2185 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2188 case ETIR__C_OPR_NEG
: /* Negate. */
2189 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2190 if (rel1
!= RELC_NONE
)
2192 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2195 case ETIR__C_OPR_COM
: /* Complement. */
2196 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2197 if (rel1
!= RELC_NONE
)
2199 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2202 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2203 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2204 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2205 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2208 (*_bfd_error_handler
) (_("invalid use of %s with contexts"),
2209 _bfd_vms_etir_name (cmd
));
2212 if ((int)op2
< 0) /* Shift right. */
2214 else /* Shift left. */
2216 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2219 case ETIR__C_OPR_INSV
: /* Insert field. */
2220 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2221 case ETIR__C_OPR_ROT
: /* Rotate. */
2222 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2223 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2224 (*_bfd_error_handler
) (_("%s: not supported"),
2225 _bfd_vms_etir_name (cmd
));
2229 case ETIR__C_OPR_SEL
: /* Select. */
2230 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2232 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2235 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2236 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2237 _bfd_vms_push (abfd
, op1
, rel1
);
2242 (*_bfd_error_handler
) (_("reserved cmd %d"), cmd
);
2247 ptr
+= cmd_length
- 4;
2253 /* Process EDBG/ETBT record.
2254 Return TRUE on success, FALSE on error */
2257 vms_slurp_debug (bfd
*abfd
)
2259 asection
*section
= PRIV (dst_section
);
2261 if (section
== NULL
)
2263 /* We have no way to find out beforehand how much debug info there
2264 is in an object file, so pick an initial amount and grow it as
2266 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2269 section
= bfd_make_section (abfd
, "$DST$");
2272 if (!bfd_set_section_flags (abfd
, section
, flags
))
2274 PRIV (dst_section
) = section
;
2277 PRIV (image_section
) = section
;
2278 PRIV (image_offset
) = section
->size
;
2280 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2283 section
->size
= PRIV (image_offset
);
2287 /* Process EDBG record.
2288 Return TRUE on success, FALSE on error. */
2291 _bfd_vms_slurp_edbg (bfd
*abfd
)
2293 vms_debug2 ((2, "EDBG\n"));
2295 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2297 return vms_slurp_debug (abfd
);
2300 /* Process ETBT record.
2301 Return TRUE on success, FALSE on error. */
2304 _bfd_vms_slurp_etbt (bfd
*abfd
)
2306 vms_debug2 ((2, "ETBT\n"));
2308 abfd
->flags
|= HAS_LINENO
;
2310 return vms_slurp_debug (abfd
);
2313 /* Process EEOM record.
2314 Return TRUE on success, FALSE on error. */
2317 _bfd_vms_slurp_eeom (bfd
*abfd
)
2319 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2321 vms_debug2 ((2, "EEOM\n"));
2323 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2324 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2325 if (PRIV (eom_data
).eom_w_comcod
> 1)
2327 (*_bfd_error_handler
) (_("Object module NOT error-free !\n"));
2328 bfd_set_error (bfd_error_bad_value
);
2332 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2333 if (PRIV (recrd
.rec_size
) > 10)
2335 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2336 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2337 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2338 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2340 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2345 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2348 _bfd_vms_slurp_object_records (bfd
* abfd
)
2355 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2357 type
= _bfd_vms_get_object_record (abfd
);
2360 vms_debug2 ((2, "next_record failed\n"));
2367 err
= _bfd_vms_slurp_ehdr (abfd
);
2370 err
= _bfd_vms_slurp_eeom (abfd
);
2373 err
= _bfd_vms_slurp_egsd (abfd
);
2376 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2379 err
= _bfd_vms_slurp_edbg (abfd
);
2382 err
= _bfd_vms_slurp_etbt (abfd
);
2389 vms_debug2 ((2, "slurp type %d failed\n", type
));
2393 while (type
!= EOBJ__C_EEOM
);
2398 /* Initialize private data */
2400 vms_initialize (bfd
* abfd
)
2404 amt
= sizeof (struct vms_private_data_struct
);
2405 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2406 if (abfd
->tdata
.any
== NULL
)
2409 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2411 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2412 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2413 if (PRIV (stack
) == NULL
)
2419 bfd_release (abfd
, abfd
->tdata
.any
);
2420 abfd
->tdata
.any
= NULL
;
2424 /* Check the format for a file being read.
2425 Return a (bfd_target *) if it's an object file or zero if not. */
2427 static const struct bfd_target
*
2428 alpha_vms_object_p (bfd
*abfd
)
2430 PTR tdata_save
= abfd
->tdata
.any
;
2431 unsigned int test_len
;
2434 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2436 /* Allocate alpha-vms specific data. */
2437 if (!vms_initialize (abfd
))
2440 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2441 goto err_wrong_format
;
2443 /* The first challenge with VMS is to discover the kind of the file.
2445 Image files (executable or shared images) are stored as a raw
2446 stream of bytes (like on UNIX), but there is no magic number.
2448 Object files are written with RMS (record management service), ie
2449 each records are preceeded by its length (on a word - 2 bytes), and
2450 padded for word-alignment. That would be simple but when files
2451 are transfered to a UNIX filesystem (using ftp), records are lost.
2452 Only the raw content of the records are transfered. Fortunately,
2453 the Alpha Object file format also store the length of the record
2454 in the records. Is that clear ? */
2456 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2457 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2458 4 bytes minor id, 4 bytes length). */
2461 /* Size the main buffer. */
2462 buf
= (unsigned char *) bfd_malloc (test_len
);
2465 PRIV (recrd
.buf
) = buf
;
2466 PRIV (recrd
.buf_size
) = test_len
;
2468 /* Initialize the record pointer. */
2469 PRIV (recrd
.rec
) = buf
;
2471 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2473 bfd_set_error (bfd_error_file_truncated
);
2477 /* Is it an image? */
2478 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2479 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2481 unsigned int to_read
;
2482 unsigned int read_so_far
;
2483 unsigned int remaining
;
2484 unsigned int eisd_offset
, eihs_offset
;
2486 /* Extract the header size. */
2487 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2489 /* The header size is 0 for DSF files. */
2490 if (PRIV (recrd
.rec_size
) == 0)
2491 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2493 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2495 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2499 PRIV (recrd
.buf
) = NULL
;
2500 bfd_set_error (bfd_error_no_memory
);
2503 PRIV (recrd
.buf
) = buf
;
2504 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2507 /* Read the remaining record. */
2508 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2509 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2510 read_so_far
= test_len
;
2512 while (remaining
> 0)
2514 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2516 bfd_set_error (bfd_error_file_truncated
);
2517 goto err_wrong_format
;
2520 read_so_far
+= to_read
;
2521 remaining
-= to_read
;
2523 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2526 /* Reset the record pointer. */
2527 PRIV (recrd
.rec
) = buf
;
2529 vms_debug2 ((2, "file type is image\n"));
2531 if (_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
) != TRUE
)
2532 goto err_wrong_format
;
2534 if (_bfd_vms_slurp_eisd (abfd
, eisd_offset
) != TRUE
)
2535 goto err_wrong_format
;
2537 /* EIHS is optional. */
2538 if (eihs_offset
!= 0 && _bfd_vms_slurp_eihs (abfd
, eihs_offset
) != TRUE
)
2539 goto err_wrong_format
;
2545 /* Assume it's a module and adjust record pointer if necessary. */
2546 maybe_adjust_record_pointer_for_object (abfd
);
2548 /* But is it really a module? */
2549 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2550 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2552 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2553 goto err_wrong_format
;
2555 vms_debug2 ((2, "file type is module\n"));
2557 type
= bfd_getl16 (PRIV (recrd
.rec
));
2558 if (type
!= EOBJ__C_EMH
|| _bfd_vms_slurp_ehdr (abfd
) != TRUE
)
2559 goto err_wrong_format
;
2561 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
2562 goto err_wrong_format
;
2565 goto err_wrong_format
;
2568 /* Set arch_info to alpha. */
2570 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2571 goto err_wrong_format
;
2576 bfd_set_error (bfd_error_wrong_format
);
2579 if (PRIV (recrd
.buf
))
2580 free (PRIV (recrd
.buf
));
2581 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2582 bfd_release (abfd
, abfd
->tdata
.any
);
2583 abfd
->tdata
.any
= tdata_save
;
2589 /* Write an EMH/MHD record. */
2592 _bfd_vms_write_emh (bfd
*abfd
)
2594 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2596 _bfd_vms_output_alignment (recwr
, 2);
2599 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2600 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2601 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2602 _bfd_vms_output_long (recwr
, 0);
2603 _bfd_vms_output_long (recwr
, 0);
2604 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2606 /* Create module name from filename. */
2607 if (bfd_get_filename (abfd
) != 0)
2609 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2610 _bfd_vms_output_counted (recwr
, module
);
2614 _bfd_vms_output_counted (recwr
, "NONAME");
2616 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2617 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2618 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2619 _bfd_vms_output_end (abfd
, recwr
);
2622 /* Write an EMH/LMN record. */
2625 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2628 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2629 unsigned int ver
= BFD_VERSION
/ 10000;
2632 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2633 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2634 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2635 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2636 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2637 _bfd_vms_output_end (abfd
, recwr
);
2641 /* Write eom record for bfd abfd. Return FALSE on error. */
2644 _bfd_vms_write_eeom (bfd
*abfd
)
2646 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2648 vms_debug2 ((2, "vms_write_eeom\n"));
2650 _bfd_vms_output_alignment (recwr
, 2);
2652 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2653 _bfd_vms_output_long (recwr
, (unsigned long) (PRIV (vms_linkage_index
) >> 1));
2654 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2655 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2657 if ((abfd
->flags
& EXEC_P
) == 0
2658 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2662 section
= bfd_get_section_by_name (abfd
, ".link");
2665 bfd_set_error (bfd_error_nonrepresentable_section
);
2668 _bfd_vms_output_short (recwr
, 0);
2669 _bfd_vms_output_long (recwr
, (unsigned long) (section
->index
));
2670 _bfd_vms_output_long (recwr
,
2671 (unsigned long) bfd_get_start_address (abfd
));
2672 _bfd_vms_output_long (recwr
, 0);
2675 _bfd_vms_output_end (abfd
, recwr
);
2679 /* This hash routine borrowed from GNU-EMACS, and strengthened
2683 hash_string (const char *ptr
)
2685 const unsigned char *p
= (unsigned char *) ptr
;
2686 const unsigned char *end
= p
+ strlen (ptr
);
2693 hash
= ((hash
<< 3) + (hash
<< 15) + (hash
>> 28) + c
);
2698 /* Generate a length-hashed VMS symbol name (limited to maxlen chars). */
2701 _bfd_vms_length_hash_symbol (bfd
*abfd
, const char *in
, int maxlen
)
2703 unsigned long result
;
2706 const char *old_name
;
2708 static char outbuf
[EOBJ__C_SYMSIZ
+ 1];
2712 vms_debug (4, "_bfd_vms_length_hash_symbol \"%s\"\n", in
);
2715 if (maxlen
> EOBJ__C_SYMSIZ
)
2716 maxlen
= EOBJ__C_SYMSIZ
;
2718 /* Save this for later. */
2721 /* We may need to truncate the symbol, save the hash for later. */
2722 in_len
= strlen (in
);
2724 result
= (in_len
> maxlen
) ? hash_string (in
) : 0;
2728 /* Do the length checking. */
2729 if (in_len
<= maxlen
)
2733 if (PRIV (flag_hash_long_names
))
2739 strncpy (out
, in
, (size_t) i
);
2743 if ((in_len
> maxlen
)
2744 && PRIV (flag_hash_long_names
))
2745 sprintf (out
, "_%08lx", result
);
2750 vms_debug (4, "--> [%d]\"%s\"\n", (int)strlen (outbuf
), outbuf
);
2754 && PRIV (flag_hash_long_names
)
2755 && PRIV (flag_show_after_trunc
))
2756 printf (_("Symbol %s replaced by %s\n"), old_name
, new_name
);
2762 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2764 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2767 if (vec
->max_el
== 0)
2770 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2775 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2779 /* Bump ABFD file position to next block. */
2782 alpha_vms_file_position_block (bfd
*abfd
)
2785 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2786 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2789 /* Convert from internal structure SRC to external structure DST. */
2792 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2793 struct vms_eisd
*dst
)
2795 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2796 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2797 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2798 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2800 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2801 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2802 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2803 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2804 dst
->pfc
= src
->u
.eisd
.pfc
;
2805 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2806 dst
->type
= src
->u
.eisd
.type
;
2808 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2810 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2811 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2812 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2816 /* Append EISD to the list of extra eisd for ABFD. */
2819 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2822 if (PRIV (gbl_eisd_head
) == NULL
)
2823 PRIV (gbl_eisd_head
) = eisd
;
2825 PRIV (gbl_eisd_tail
)->next
= eisd
;
2826 PRIV (gbl_eisd_tail
) = eisd
;
2829 /* Create an EISD for shared image SHRIMG.
2830 Return FALSE in case of error. */
2833 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2835 struct vms_internal_eisd_map
*eisd
;
2838 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2839 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2845 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2849 /* Fill the fields. */
2850 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2851 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2852 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2853 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2854 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2855 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2856 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2857 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2858 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2859 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2861 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2862 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2863 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2865 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2867 /* Append it to the list. */
2868 alpha_vms_append_extra_eisd (abfd
, eisd
);
2873 /* Create an EISD for section SEC.
2874 Return FALSE in case of failure. */
2877 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2879 struct vms_internal_eisd_map
*eisd
;
2881 /* Only for allocating section. */
2882 if (!(sec
->flags
& SEC_ALLOC
))
2885 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2886 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2889 vms_section_data (sec
)->eisd
= eisd
;
2891 /* Fill the fields. */
2892 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2893 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2894 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2895 eisd
->u
.eisd
.secsize
=
2896 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2897 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2898 eisd
->u
.eisd
.flags
= 0;
2899 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2900 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2901 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2902 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2904 if (sec
->flags
& SEC_CODE
)
2905 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2906 if (!(sec
->flags
& SEC_READONLY
))
2907 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2909 if (!(sec
->flags
& SEC_LOAD
))
2911 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
2912 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
2914 if (sec
->flags
& SEC_LINKER_CREATED
)
2916 if (strcmp (sec
->name
, "$FIXUP$") == 0)
2917 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
2920 /* Append it to the list. */
2922 if (PRIV (eisd_head
) == NULL
)
2923 PRIV (eisd_head
) = eisd
;
2925 PRIV (eisd_tail
)->next
= eisd
;
2926 PRIV (eisd_tail
) = eisd
;
2931 /* Layout executable ABFD and write it to the disk.
2932 Return FALSE in case of failure. */
2935 alpha_vms_write_exec (bfd
*abfd
)
2937 struct vms_eihd eihd
;
2938 struct vms_eiha
*eiha
;
2939 struct vms_eihi
*eihi
;
2940 struct vms_eihs
*eihs
= NULL
;
2942 struct vms_internal_eisd_map
*first_eisd
;
2943 struct vms_internal_eisd_map
*eisd
;
2946 file_ptr gst_filepos
= 0;
2947 unsigned int lnkflags
= 0;
2949 /* Build the EIHD. */
2950 PRIV (file_pos
) = EIHD__C_LENGTH
;
2952 memset (&eihd
, 0, sizeof (eihd
));
2953 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
2955 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
2956 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
2958 bfd_putl32 (sizeof (eihd
), eihd
.size
);
2959 bfd_putl32 (0, eihd
.isdoff
);
2960 bfd_putl32 (0, eihd
.activoff
);
2961 bfd_putl32 (0, eihd
.symdbgoff
);
2962 bfd_putl32 (0, eihd
.imgidoff
);
2963 bfd_putl32 (0, eihd
.patchoff
);
2964 bfd_putl64 (0, eihd
.iafva
);
2965 bfd_putl32 (0, eihd
.version_array_off
);
2967 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
2968 bfd_putl32 (0, eihd
.subtype
);
2970 bfd_putl32 (0, eihd
.imgiocnt
);
2971 bfd_putl32 (-1, eihd
.privreqs
);
2972 bfd_putl32 (-1, eihd
.privreqs
+ 4);
2974 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2976 bfd_putl32 (0, eihd
.ident
);
2977 bfd_putl32 (0, eihd
.sysver
);
2980 bfd_putl32 (0, eihd
.symvect_size
);
2981 bfd_putl32 (16, eihd
.virt_mem_block_size
);
2982 bfd_putl32 (0, eihd
.ext_fixup_off
);
2983 bfd_putl32 (0, eihd
.noopt_psect_off
);
2984 bfd_putl32 (-1, eihd
.alias
);
2987 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
2988 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
2989 PRIV (file_pos
) += sizeof (struct vms_eiha
);
2991 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
2992 bfd_putl32 (0, eiha
->spare
);
2993 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
2994 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
2995 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
2996 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
2997 bfd_putl64 (0, eiha
->inishr
);
3000 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
3001 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
3002 PRIV (file_pos
) += sizeof (struct vms_eihi
);
3004 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
3005 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
3010 /* Set module name. */
3011 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3012 len
= strlen (module
);
3013 if (len
> sizeof (eihi
->imgnam
) - 1)
3014 len
= sizeof (eihi
->imgnam
) - 1;
3015 eihi
->imgnam
[0] = len
;
3016 memcpy (eihi
->imgnam
+ 1, module
, len
);
3024 vms_get_time (&hi
, &lo
);
3025 bfd_putl32 (lo
, eihi
->linktime
+ 0);
3026 bfd_putl32 (hi
, eihi
->linktime
+ 4);
3029 eihi
->linkid
[0] = 0;
3030 eihi
->imgbid
[0] = 0;
3033 dst
= PRIV (dst_section
);
3034 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
3035 if (dst
!= NULL
&& dst
->size
!= 0)
3037 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
3038 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
3039 PRIV (file_pos
) += sizeof (struct vms_eihs
);
3041 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
3042 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
3043 bfd_putl32 (0, eihs
->dstvbn
);
3044 bfd_putl32 (0, eihs
->dstsize
);
3045 bfd_putl32 (0, eihs
->gstvbn
);
3046 bfd_putl32 (0, eihs
->gstsize
);
3047 bfd_putl32 (0, eihs
->dmtvbn
);
3048 bfd_putl32 (0, eihs
->dmtsize
);
3051 /* One EISD per section. */
3052 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3054 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
3058 /* Merge section EIDS which extra ones. */
3059 if (PRIV (eisd_tail
))
3060 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
3062 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
3063 if (PRIV (gbl_eisd_tail
))
3064 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
3066 first_eisd
= PRIV (eisd_head
);
3068 /* Add end of eisd. */
3071 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
3074 eisd
->u
.eisd
.majorid
= 0;
3075 eisd
->u
.eisd
.minorid
= 0;
3076 eisd
->u
.eisd
.eisdsize
= 0;
3077 alpha_vms_append_extra_eisd (abfd
, eisd
);
3080 /* Place EISD in the file. */
3081 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3083 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3085 /* First block is a little bit special: there is a word at the end. */
3086 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3088 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3089 alpha_vms_file_position_block (abfd
);
3091 eisd
->file_pos
= PRIV (file_pos
);
3092 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3094 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3095 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3098 if (first_eisd
!= NULL
)
3100 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3101 /* Real size of end of eisd marker. */
3102 PRIV (file_pos
) += EISD__K_LENEND
;
3105 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3106 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3109 /* Place sections. */
3110 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3112 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3115 eisd
= vms_section_data (sec
)->eisd
;
3117 /* Align on a block. */
3118 alpha_vms_file_position_block (abfd
);
3119 sec
->filepos
= PRIV (file_pos
);
3122 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3124 PRIV (file_pos
) += sec
->size
;
3128 if (eihs
!= NULL
&& dst
!= NULL
)
3130 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3131 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3135 lnkflags
|= EIHD__M_DBGDMT
;
3136 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3137 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3139 if (PRIV (gsd_sym_count
) != 0)
3141 alpha_vms_file_position_block (abfd
);
3142 gst_filepos
= PRIV (file_pos
);
3143 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3144 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3148 /* Write EISD in hdr. */
3149 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3151 alpha_vms_swap_eisd_out
3152 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3154 /* Write first block. */
3155 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3156 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3159 /* Write remaining eisd. */
3162 unsigned char blk
[VMS_BLOCK_SIZE
];
3163 struct vms_internal_eisd_map
*next_eisd
;
3165 memset (blk
, 0xff, sizeof (blk
));
3166 while (eisd
!= NULL
)
3168 alpha_vms_swap_eisd_out
3170 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3172 next_eisd
= eisd
->next
;
3173 if (next_eisd
== NULL
3174 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3175 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3177 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3180 memset (blk
, 0xff, sizeof (blk
));
3186 /* Write sections. */
3187 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3189 unsigned char blk
[VMS_BLOCK_SIZE
];
3192 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3194 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3198 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3199 if (len
!= VMS_BLOCK_SIZE
)
3201 memset (blk
, 0, len
);
3202 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3208 if (gst_filepos
!= 0)
3210 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3213 _bfd_vms_write_emh (abfd
);
3214 _bfd_vms_write_lmn (abfd
, "GNU LD");
3216 /* PSC for the absolute section. */
3217 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3218 _bfd_vms_output_long (recwr
, 0);
3219 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3220 _bfd_vms_output_short (recwr
, 0);
3221 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3222 _bfd_vms_output_long (recwr
, 0);
3223 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3224 _bfd_vms_output_end_subrec (recwr
);
3225 _bfd_vms_output_end (abfd
, recwr
);
3227 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3229 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3236 _bfd_vms_output_alignment (recwr
, 8);
3237 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3238 _bfd_vms_output_long (recwr
, 0);
3240 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3241 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3242 _bfd_vms_output_short (recwr
, sym
->flags
);
3244 if (sym
->code_section
)
3245 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3248 BFD_ASSERT (sym
->code_value
== 0);
3251 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3252 _bfd_vms_output_quad
3253 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3254 _bfd_vms_output_quad (recwr
, ep
);
3255 _bfd_vms_output_quad (recwr
, val
);
3256 _bfd_vms_output_long (recwr
, 0);
3257 hash
= _bfd_vms_length_hash_symbol (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3258 _bfd_vms_output_counted (recwr
, hash
);
3259 _bfd_vms_output_end_subrec (recwr
);
3261 _bfd_vms_output_end (abfd
, recwr
);
3264 _bfd_vms_output_end (abfd
, recwr
);
3266 if (!_bfd_vms_write_eeom (abfd
))
3274 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3277 _bfd_vms_write_egsd (bfd
*abfd
)
3281 unsigned int symnum
;
3282 int last_index
= -1;
3283 char dummy_name
[10];
3285 flagword new_flags
, old_flags
;
3286 int abs_section_index
= 0;
3287 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3289 vms_debug2 ((2, "vms_write_gsd\n"));
3291 /* Output sections. */
3292 section
= abfd
->sections
;
3293 vms_debug2 ((3, "%d sections found\n", abfd
->section_count
));
3295 /* Egsd is quadword aligned. */
3296 _bfd_vms_output_alignment (recwr
, 8);
3298 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3299 _bfd_vms_output_long (recwr
, 0);
3301 while (section
!= 0)
3303 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3304 section
->index
, section
->name
, (int)section
->size
));
3306 /* Don't write out the VMS debug info section since it is in the
3307 ETBT and EDBG sections in etir. */
3308 if (!strcmp (section
->name
, ".vmsdebug"))
3311 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3312 if (_bfd_vms_output_check (recwr
, 64) < 0)
3314 _bfd_vms_output_end (abfd
, recwr
);
3315 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3316 _bfd_vms_output_long (recwr
, 0);
3319 /* Create dummy sections to keep consecutive indices. */
3320 while (section
->index
- last_index
> 1)
3322 vms_debug2 ((3, "index %d, last %d\n", section
->index
, last_index
));
3323 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3324 _bfd_vms_output_short (recwr
, 0);
3325 _bfd_vms_output_short (recwr
, 0);
3326 _bfd_vms_output_long (recwr
, 0);
3327 sprintf (dummy_name
, ".DUMMY%02d", last_index
);
3328 _bfd_vms_output_counted (recwr
, dummy_name
);
3329 _bfd_vms_output_end_subrec (recwr
);
3333 /* Don't know if this is necessary for the linker but for now it keeps
3334 vms_slurp_gsd happy. */
3335 sname
= section
->name
;
3338 /* Remove leading dot. */
3340 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3341 sname
= EVAX_CODE_NAME
;
3342 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3343 sname
= EVAX_DATA_NAME
;
3344 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3345 sname
= EVAX_BSS_NAME
;
3346 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3347 sname
= EVAX_LINK_NAME
;
3348 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3349 sname
= EVAX_READONLY_NAME
;
3350 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3351 sname
= EVAX_LITERAL_NAME
;
3352 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3354 sname
= EVAX_LITERALS_NAME
;
3355 abs_section_index
= section
->index
;
3357 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3358 sname
= EVAX_COMMON_NAME
;
3359 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3360 sname
= EVAX_LOCAL_NAME
;
3363 sname
= _bfd_vms_length_hash_symbol (abfd
, sname
, EOBJ__C_SECSIZ
);
3365 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3366 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3368 if (bfd_is_com_section (section
))
3369 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3370 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3372 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3375 /* Modify them as directed. */
3376 if (section
->flags
& SEC_READONLY
)
3377 new_flags
&= ~EGPS__V_WRT
;
3379 new_flags
&= ~vms_section_data (section
)->no_flags
;
3380 new_flags
|= vms_section_data (section
)->flags
;
3382 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3383 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3384 new_flags
, (unsigned long)section
->size
));
3386 _bfd_vms_output_short (recwr
, new_flags
);
3387 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3388 _bfd_vms_output_counted (recwr
, sname
);
3389 _bfd_vms_output_end_subrec (recwr
);
3391 last_index
= section
->index
;
3393 section
= section
->next
;
3396 /* Output symbols. */
3397 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3399 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3401 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3405 symbol
= abfd
->outsymbols
[symnum
];
3406 old_flags
= symbol
->flags
;
3408 /* Work-around a missing feature: consider __main as the main entry point. */
3409 if (*(symbol
->name
) == '_')
3411 if (strcmp (symbol
->name
, "__main") == 0)
3412 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3415 /* Only put in the GSD the global and the undefined symbols. */
3416 if (old_flags
& BSF_FILE
)
3419 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3421 /* If the LIB$INITIIALIZE section is present, add a reference to
3422 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3423 in the assembly file. */
3424 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3425 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3429 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. */
3430 if (_bfd_vms_output_check (recwr
, 80) < 0)
3432 _bfd_vms_output_end (abfd
, recwr
);
3433 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3434 _bfd_vms_output_long (recwr
, 0);
3437 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3439 /* Data type, alignment. */
3440 _bfd_vms_output_short (recwr
, 0);
3444 if (old_flags
& BSF_WEAK
)
3445 new_flags
|= EGSY__V_WEAK
;
3446 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3447 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3449 if (old_flags
& BSF_FUNCTION
)
3451 new_flags
|= EGSY__V_NORM
;
3452 new_flags
|= EGSY__V_REL
;
3454 if (old_flags
& BSF_GLOBAL
)
3456 new_flags
|= EGSY__V_DEF
;
3457 if (!bfd_is_abs_section (symbol
->section
))
3458 new_flags
|= EGSY__V_REL
;
3460 _bfd_vms_output_short (recwr
, new_flags
);
3462 if (old_flags
& BSF_GLOBAL
)
3464 /* Symbol definition. */
3465 bfd_vma code_address
= 0;
3466 unsigned long ca_psindx
= 0;
3467 unsigned long psindx
;
3469 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3473 sym
= ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3474 code_address
= sym
->value
;
3475 ca_psindx
= sym
->section
->index
;
3477 if (bfd_is_abs_section (symbol
->section
))
3478 psindx
= abs_section_index
;
3480 psindx
= symbol
->section
->index
;
3482 _bfd_vms_output_quad (recwr
, symbol
->value
);
3483 _bfd_vms_output_quad (recwr
, code_address
);
3484 _bfd_vms_output_long (recwr
, ca_psindx
);
3485 _bfd_vms_output_long (recwr
, psindx
);
3487 hash
= _bfd_vms_length_hash_symbol (abfd
, symbol
->name
, EOBJ__C_SYMSIZ
);
3488 _bfd_vms_output_counted (recwr
, hash
);
3490 _bfd_vms_output_end_subrec (recwr
);
3493 _bfd_vms_output_alignment (recwr
, 8);
3494 _bfd_vms_output_end (abfd
, recwr
);
3499 /* Write object header for bfd abfd. Return FALSE on error. */
3502 _bfd_vms_write_ehdr (bfd
*abfd
)
3505 unsigned int symnum
;
3508 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3510 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3512 _bfd_vms_output_alignment (recwr
, 2);
3514 _bfd_vms_write_emh (abfd
);
3515 _bfd_vms_write_lmn (abfd
, "GNU AS");
3518 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3519 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3521 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3523 symbol
= abfd
->outsymbols
[symnum
];
3525 if (symbol
->flags
& BSF_FILE
)
3527 if (CONST_STRNEQ ((char *)symbol
->name
, "<CASE:"))
3529 PRIV (flag_hash_long_names
) = symbol
->name
[6] - '0';
3530 PRIV (flag_show_after_trunc
) = symbol
->name
[7] - '0';
3538 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3539 (int) strlen (symbol
->name
));
3546 if (symnum
== abfd
->symcount
)
3547 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3549 _bfd_vms_output_end (abfd
, recwr
);
3552 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3553 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3554 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3555 _bfd_vms_output_end (abfd
, recwr
);
3558 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3559 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3560 _bfd_vms_output_dump (recwr
,
3561 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3563 _bfd_vms_output_end (abfd
, recwr
);
3568 /* Part 4.6, relocations. */
3571 /* WRITE ETIR SECTION
3573 This is still under construction and therefore not documented. */
3575 /* Close the etir/etbt record. */
3578 end_etir_record (bfd
* abfd
)
3580 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3582 _bfd_vms_output_end (abfd
, recwr
);
3586 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3588 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3590 if (section
->name
[0] == '.' && section
->name
[1] == 'v'
3591 && !strcmp (section
->name
, ".vmsdebug"))
3593 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3597 /* Push start offset. */
3598 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3599 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3600 _bfd_vms_output_end_subrec (recwr
);
3603 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3604 _bfd_vms_output_end_subrec (recwr
);
3609 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3613 /* Push start offset. */
3614 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3615 _bfd_vms_output_long (recwr
, (unsigned long) section
->index
);
3616 _bfd_vms_output_quad (recwr
, offset
);
3617 _bfd_vms_output_end_subrec (recwr
);
3619 /* Start = pop (). */
3620 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3621 _bfd_vms_output_end_subrec (recwr
);
3626 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3627 address VADDR in section specified by SEC_INDEX and NAME. */
3630 sto_imm (bfd
*abfd
, asection
*section
,
3631 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3634 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3637 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3638 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3643 /* Try all the rest. */
3646 if (_bfd_vms_output_check (recwr
, size
) < 0)
3648 /* Doesn't fit, split ! */
3649 end_etir_record (abfd
);
3651 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3653 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3654 if (size
> ssize
) /* more than what's left ? */
3658 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3659 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3660 _bfd_vms_output_dump (recwr
, cptr
, size
);
3661 _bfd_vms_output_end_subrec (recwr
);
3664 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3665 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3675 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3677 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3679 /* Not enough room in this record. Close it and open a new one. */
3680 end_etir_record (abfd
);
3681 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3685 /* Return whether RELOC must be deferred till the end. */
3688 defer_reloc_p (arelent
*reloc
)
3690 switch (reloc
->howto
->type
)
3703 /* Write section contents for bfd abfd. Return FALSE on error. */
3706 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3709 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3711 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3713 _bfd_vms_output_alignment (recwr
, 4);
3715 PRIV (vms_linkage_index
) = 1;
3717 for (section
= abfd
->sections
; section
; section
= section
->next
)
3719 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3720 section
->index
, section
->name
, (int) (section
->size
)));
3722 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3723 || bfd_is_com_section (section
))
3726 if (!section
->contents
)
3728 bfd_set_error (bfd_error_no_contents
);
3732 start_etir_or_etbt_record (abfd
, section
, 0);
3734 if (section
->flags
& SEC_RELOC
)
3736 bfd_vma curr_addr
= 0;
3737 unsigned char *curr_data
= section
->contents
;
3739 int pass2_needed
= 0;
3740 int pass2_in_progress
= 0;
3743 if (section
->reloc_count
<= 0)
3744 (*_bfd_error_handler
)
3745 (_("SEC_RELOC with no relocs in section %s"), section
->name
);
3750 int i
= section
->reloc_count
;
3751 arelent
**rptr
= section
->orelocation
;
3752 _bfd_vms_debug (4, "%d relocations:\n", i
);
3755 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3756 "addr %08lx, off %08lx, len %d: %s\n",
3757 (*(*rptr
)->sym_ptr_ptr
)->name
,
3758 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3759 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3760 (unsigned long)(*rptr
)->address
,
3761 (unsigned long)(*rptr
)->addend
,
3762 bfd_get_reloc_size ((*rptr
)->howto
),
3763 ( *rptr
)->howto
->name
);
3770 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3772 struct evax_private_udata_struct
*udata
;
3773 arelent
*rptr
= section
->orelocation
[irel
];
3774 bfd_vma addr
= rptr
->address
;
3775 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3776 asection
*sec
= sym
->section
;
3777 bfd_boolean defer
= defer_reloc_p (rptr
);
3781 if (pass2_in_progress
)
3783 /* Non-deferred relocs have already been output. */
3789 /* Deferred relocs must be output at the very end. */
3796 /* Regular relocs are intertwined with binary data. */
3797 if (curr_addr
> addr
)
3798 (*_bfd_error_handler
) (_("Size error in section %s"),
3800 size
= addr
- curr_addr
;
3801 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3806 size
= bfd_get_reloc_size (rptr
->howto
);
3808 switch (rptr
->howto
->type
)
3810 case ALPHA_R_IGNORE
:
3813 case ALPHA_R_REFLONG
:
3814 if (bfd_is_und_section (sym
->section
))
3816 bfd_vma addend
= rptr
->addend
;
3817 slen
= strlen ((char *) sym
->name
);
3818 hash
= _bfd_vms_length_hash_symbol
3819 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3820 etir_output_check (abfd
, section
, curr_addr
, slen
);
3823 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3824 _bfd_vms_output_counted (recwr
, hash
);
3825 _bfd_vms_output_end_subrec (recwr
);
3826 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3827 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3828 _bfd_vms_output_end_subrec (recwr
);
3829 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3830 _bfd_vms_output_end_subrec (recwr
);
3831 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3832 _bfd_vms_output_end_subrec (recwr
);
3836 _bfd_vms_output_begin_subrec
3837 (recwr
, ETIR__C_STO_GBL_LW
);
3838 _bfd_vms_output_counted (recwr
, hash
);
3839 _bfd_vms_output_end_subrec (recwr
);
3842 else if (bfd_is_abs_section (sym
->section
))
3844 etir_output_check (abfd
, section
, curr_addr
, 16);
3845 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3846 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3847 _bfd_vms_output_end_subrec (recwr
);
3848 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3849 _bfd_vms_output_end_subrec (recwr
);
3853 etir_output_check (abfd
, section
, curr_addr
, 32);
3854 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3855 _bfd_vms_output_long (recwr
, (unsigned long) sec
->index
);
3856 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3857 _bfd_vms_output_end_subrec (recwr
);
3858 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3859 says that we should have a ETIR__C_STO_OFF here.
3860 But the relocation would not be BFD_RELOC_32 then.
3861 This case is very likely unreachable. */
3862 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3863 _bfd_vms_output_end_subrec (recwr
);
3867 case ALPHA_R_REFQUAD
:
3868 if (bfd_is_und_section (sym
->section
))
3870 bfd_vma addend
= rptr
->addend
;
3871 slen
= strlen ((char *) sym
->name
);
3872 hash
= _bfd_vms_length_hash_symbol
3873 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3874 etir_output_check (abfd
, section
, curr_addr
, slen
);
3877 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3878 _bfd_vms_output_counted (recwr
, hash
);
3879 _bfd_vms_output_end_subrec (recwr
);
3880 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3881 _bfd_vms_output_quad (recwr
, addend
);
3882 _bfd_vms_output_end_subrec (recwr
);
3883 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3884 _bfd_vms_output_end_subrec (recwr
);
3885 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3886 _bfd_vms_output_end_subrec (recwr
);
3890 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3891 _bfd_vms_output_counted (recwr
, hash
);
3892 _bfd_vms_output_end_subrec (recwr
);
3895 else if (bfd_is_abs_section (sym
->section
))
3897 etir_output_check (abfd
, section
, curr_addr
, 16);
3898 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3899 _bfd_vms_output_quad (recwr
, sym
->value
);
3900 _bfd_vms_output_end_subrec (recwr
);
3901 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3902 _bfd_vms_output_end_subrec (recwr
);
3906 etir_output_check (abfd
, section
, curr_addr
, 32);
3907 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3908 _bfd_vms_output_long (recwr
, (unsigned long) sec
->index
);
3909 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3910 _bfd_vms_output_end_subrec (recwr
);
3911 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3912 _bfd_vms_output_end_subrec (recwr
);
3917 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3920 case ALPHA_R_LINKAGE
:
3921 etir_output_check (abfd
, section
, curr_addr
, 64);
3922 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
3923 _bfd_vms_output_long
3924 (recwr
, (unsigned long) PRIV (vms_linkage_index
));
3925 PRIV (vms_linkage_index
) += 2;
3926 hash
= _bfd_vms_length_hash_symbol
3927 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3928 _bfd_vms_output_counted (recwr
, hash
);
3929 _bfd_vms_output_byte (recwr
, 0);
3930 _bfd_vms_output_end_subrec (recwr
);
3933 case ALPHA_R_CODEADDR
:
3934 slen
= strlen ((char *) sym
->name
);
3935 hash
= _bfd_vms_length_hash_symbol
3936 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3937 etir_output_check (abfd
, section
, curr_addr
, slen
);
3938 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
3939 _bfd_vms_output_counted (recwr
, hash
);
3940 _bfd_vms_output_end_subrec (recwr
);
3945 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3946 etir_output_check (abfd
, section
, curr_addr
,
3947 32 + 1 + strlen (udata
->origname
));
3948 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
3949 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3950 _bfd_vms_output_long
3951 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3952 _bfd_vms_output_quad (recwr
, rptr
->address
);
3953 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
3954 _bfd_vms_output_long
3955 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3956 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3957 _bfd_vms_output_counted
3958 (recwr
, _bfd_vms_length_hash_symbol
3959 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3960 _bfd_vms_output_end_subrec (recwr
);
3964 (*_bfd_error_handler
) (_("Spurious ALPHA_R_BSR reloc"));
3969 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3970 etir_output_check (abfd
, section
, curr_addr
,
3971 32 + 1 + strlen (udata
->origname
));
3972 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
3973 _bfd_vms_output_long
3974 (recwr
, (unsigned long) udata
->lkindex
+ 1);
3975 _bfd_vms_output_long
3976 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3977 _bfd_vms_output_quad (recwr
, rptr
->address
);
3978 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
3979 _bfd_vms_output_long
3980 (recwr
, (unsigned long) udata
->bsym
->section
->index
);
3981 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3982 _bfd_vms_output_counted
3983 (recwr
, _bfd_vms_length_hash_symbol
3984 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3985 _bfd_vms_output_end_subrec (recwr
);
3990 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3991 etir_output_check (abfd
, section
, curr_addr
,
3992 32 + 1 + strlen (udata
->origname
));
3993 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
3994 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3995 _bfd_vms_output_long
3996 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3997 _bfd_vms_output_quad (recwr
, rptr
->address
);
3998 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
3999 _bfd_vms_output_long
4000 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
4001 _bfd_vms_output_quad (recwr
, rptr
->addend
);
4002 _bfd_vms_output_counted
4003 (recwr
, _bfd_vms_length_hash_symbol
4004 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
4005 _bfd_vms_output_end_subrec (recwr
);
4009 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
4016 } /* End of relocs loop. */
4018 if (!pass2_in_progress
)
4020 /* Output rest of section. */
4021 if (curr_addr
> section
->size
)
4022 (*_bfd_error_handler
) (_("Size error in section %s"),
4024 size
= section
->size
- curr_addr
;
4025 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
4031 pass2_in_progress
= 1;
4037 else /* (section->flags & SEC_RELOC) */
4038 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
4040 end_etir_record (abfd
);
4043 _bfd_vms_output_alignment (recwr
, 2);
4047 /* Write cached information into a file being written, at bfd_close. */
4050 alpha_vms_write_object_contents (bfd
*abfd
)
4052 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
4054 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
4056 return alpha_vms_write_exec (abfd
);
4060 if (abfd
->section_count
> 0) /* we have sections */
4062 if (_bfd_vms_write_ehdr (abfd
) != TRUE
)
4064 if (_bfd_vms_write_egsd (abfd
) != TRUE
)
4066 if (_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
) != TRUE
)
4068 if (_bfd_vms_write_eeom (abfd
) != TRUE
)
4075 /* Debug stuff: nearest line. */
4077 #define SET_MODULE_PARSED(m) \
4078 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
4079 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
4081 /* Build a new module for the specified BFD. */
4083 static struct module
*
4084 new_module (bfd
*abfd
)
4086 struct module
*module
4087 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
4088 module
->file_table_count
= 16; /* Arbitrary. */
4090 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
4094 /* Parse debug info for a module and internalize it. */
4097 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
4100 unsigned char *maxptr
= ptr
+ length
;
4101 unsigned char *src_ptr
, *pcl_ptr
;
4102 unsigned int prev_linum
= 0, curr_linenum
= 0;
4103 bfd_vma prev_pc
= 0, curr_pc
= 0;
4104 struct srecinfo
*curr_srec
, *srec
;
4105 struct lineinfo
*curr_line
, *line
;
4106 struct funcinfo
*funcinfo
;
4108 /* Initialize tables with zero element. */
4109 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4110 module
->srec_table
= curr_srec
;
4112 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4113 module
->line_table
= curr_line
;
4115 while (length
== -1 || ptr
< maxptr
)
4117 /* The first byte is not counted in the recorded length. */
4118 int rec_length
= bfd_getl16 (ptr
) + 1;
4119 int rec_type
= bfd_getl16 (ptr
+ 2);
4121 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4123 if (length
== -1 && rec_type
== DST__K_MODEND
)
4130 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
);
4137 vms_debug2 ((3, "module: %s\n", module
->name
));
4144 funcinfo
= (struct funcinfo
*)
4145 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4147 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
);
4148 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4149 funcinfo
->next
= module
->func_table
;
4150 module
->func_table
= funcinfo
;
4152 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4153 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4157 module
->func_table
->high
= module
->func_table
->low
4158 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4160 if (module
->func_table
->high
> module
->high
)
4161 module
->high
= module
->func_table
->high
;
4163 vms_debug2 ((3, "end routine\n"));
4167 vms_debug2 ((3, "prologue\n"));
4171 vms_debug2 ((3, "epilog\n"));
4175 vms_debug2 ((3, "block\n"));
4179 vms_debug2 ((3, "end block\n"));
4183 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4185 vms_debug2 ((3, "source info\n"));
4187 while (src_ptr
< ptr
+ rec_length
)
4189 int cmd
= src_ptr
[0], cmd_length
, data
;
4193 case DST__K_SRC_DECLFILE
:
4196 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4198 = _bfd_vms_save_counted_string (src_ptr
4199 + DST_S_B_SRC_DF_FILENAME
);
4201 while (fileid
>= module
->file_table_count
)
4203 module
->file_table_count
*= 2;
4205 = bfd_realloc (module
->file_table
,
4206 module
->file_table_count
4207 * sizeof (struct fileinfo
));
4210 module
->file_table
[fileid
].name
= filename
;
4211 module
->file_table
[fileid
].srec
= 1;
4212 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4213 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4214 fileid
, module
->file_table
[fileid
].name
));
4218 case DST__K_SRC_DEFLINES_B
:
4219 /* Perform the association and set the next higher index
4221 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4222 srec
= (struct srecinfo
*)
4223 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4224 srec
->line
= curr_srec
->line
+ data
;
4225 srec
->srec
= curr_srec
->srec
+ data
;
4226 srec
->sfile
= curr_srec
->sfile
;
4227 curr_srec
->next
= srec
;
4230 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4233 case DST__K_SRC_DEFLINES_W
:
4234 /* Perform the association and set the next higher index
4236 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4237 srec
= (struct srecinfo
*)
4238 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4239 srec
->line
= curr_srec
->line
+ data
;
4240 srec
->srec
= curr_srec
->srec
+ data
,
4241 srec
->sfile
= curr_srec
->sfile
;
4242 curr_srec
->next
= srec
;
4245 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4248 case DST__K_SRC_INCRLNUM_B
:
4249 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4250 curr_srec
->line
+= data
;
4252 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4255 case DST__K_SRC_SETFILE
:
4256 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4257 curr_srec
->sfile
= data
;
4258 curr_srec
->srec
= module
->file_table
[data
].srec
;
4260 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4263 case DST__K_SRC_SETLNUM_L
:
4264 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4265 curr_srec
->line
= data
;
4267 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4270 case DST__K_SRC_SETLNUM_W
:
4271 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4272 curr_srec
->line
= data
;
4274 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4277 case DST__K_SRC_SETREC_L
:
4278 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4279 curr_srec
->srec
= data
;
4280 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4282 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4285 case DST__K_SRC_SETREC_W
:
4286 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4287 curr_srec
->srec
= data
;
4288 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4290 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4293 case DST__K_SRC_FORMFEED
:
4295 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4299 (*_bfd_error_handler
) (_("unknown source command %d"),
4305 src_ptr
+= cmd_length
;
4309 case DST__K_LINE_NUM
:
4310 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4312 vms_debug2 ((3, "line info\n"));
4314 while (pcl_ptr
< ptr
+ rec_length
)
4316 /* The command byte is signed so we must sign-extend it. */
4317 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4321 case DST__K_DELTA_PC_W
:
4322 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4326 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4329 case DST__K_DELTA_PC_L
:
4330 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4334 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4337 case DST__K_INCR_LINUM
:
4338 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4339 curr_linenum
+= data
;
4341 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4344 case DST__K_INCR_LINUM_W
:
4345 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4346 curr_linenum
+= data
;
4348 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4351 case DST__K_INCR_LINUM_L
:
4352 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4353 curr_linenum
+= data
;
4355 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4358 case DST__K_SET_LINUM_INCR
:
4359 (*_bfd_error_handler
)
4360 (_("DST__K_SET_LINUM_INCR not implemented"));
4364 case DST__K_SET_LINUM_INCR_W
:
4365 (*_bfd_error_handler
)
4366 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4370 case DST__K_RESET_LINUM_INCR
:
4371 (*_bfd_error_handler
)
4372 (_("DST__K_RESET_LINUM_INCR not implemented"));
4376 case DST__K_BEG_STMT_MODE
:
4377 (*_bfd_error_handler
)
4378 (_("DST__K_BEG_STMT_MODE not implemented"));
4382 case DST__K_END_STMT_MODE
:
4383 (*_bfd_error_handler
)
4384 (_("DST__K_END_STMT_MODE not implemented"));
4388 case DST__K_SET_LINUM_B
:
4389 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4390 curr_linenum
= data
;
4392 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4395 case DST__K_SET_LINUM
:
4396 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4397 curr_linenum
= data
;
4399 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4402 case DST__K_SET_LINUM_L
:
4403 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4404 curr_linenum
= data
;
4406 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4410 (*_bfd_error_handler
)
4411 (_("DST__K_SET_PC not implemented"));
4415 case DST__K_SET_PC_W
:
4416 (*_bfd_error_handler
)
4417 (_("DST__K_SET_PC_W not implemented"));
4421 case DST__K_SET_PC_L
:
4422 (*_bfd_error_handler
)
4423 (_("DST__K_SET_PC_L not implemented"));
4427 case DST__K_SET_STMTNUM
:
4428 (*_bfd_error_handler
)
4429 (_("DST__K_SET_STMTNUM not implemented"));
4434 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4437 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4441 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4444 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4448 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4451 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4454 case DST__K_SET_ABS_PC
:
4455 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4458 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4467 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4468 (unsigned long)curr_pc
, curr_linenum
));
4472 (*_bfd_error_handler
) (_("unknown line command %d"),
4479 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4481 || cmd
== DST__K_DELTA_PC_L
4482 || cmd
== DST__K_DELTA_PC_W
)
4484 line
= (struct lineinfo
*)
4485 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4486 line
->address
= curr_pc
;
4487 line
->line
= curr_linenum
;
4489 curr_line
->next
= line
;
4492 prev_linum
= curr_linenum
;
4494 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4495 (unsigned long)curr_pc
, curr_linenum
));
4498 pcl_ptr
+= cmd_length
;
4502 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4503 vms_debug2 ((3, "undocumented type 0x17\n"));
4507 vms_debug2 ((3, "ignoring record\n"));
4515 /* Finalize tables with EOL marker. */
4516 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4517 srec
->line
= (unsigned int) -1;
4518 srec
->srec
= (unsigned int) -1;
4519 curr_srec
->next
= srec
;
4521 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4522 line
->line
= (unsigned int) -1;
4523 line
->address
= (bfd_vma
) -1;
4524 curr_line
->next
= line
;
4526 /* Advertise that this module has been parsed. This is needed
4527 because parsing can be either performed at module creation
4528 or deferred until debug info is consumed. */
4529 SET_MODULE_PARSED (module
);
4532 /* Build the list of modules for the specified BFD. */
4534 static struct module
*
4535 build_module_list (bfd
*abfd
)
4537 struct module
*module
, *list
= NULL
;
4540 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4542 /* We have a DMT section so this must be an image. Parse the
4543 section and build the list of modules. This is sufficient
4544 since we can compute the start address and the end address
4545 of every module from the section contents. */
4546 bfd_size_type size
= bfd_get_section_size (dmt
);
4547 unsigned char *ptr
, *end
;
4549 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4553 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4556 vms_debug2 ((2, "DMT\n"));
4562 /* Each header declares a module with its start offset and size
4563 of debug info in the DST section, as well as the count of
4564 program sections (i.e. address spans) it contains. */
4565 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4566 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4567 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4568 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4570 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4571 modbeg
, msize
, count
));
4573 /* We create a 'module' structure for each program section since
4574 we only support contiguous addresses in a 'module' structure.
4575 As a consequence, the actual debug info in the DST section is
4576 shared and can be parsed multiple times; that doesn't seem to
4577 cause problems in practice. */
4580 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4581 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4582 module
= new_module (abfd
);
4583 module
->modbeg
= modbeg
;
4584 module
->size
= msize
;
4585 module
->low
= start
;
4586 module
->high
= start
+ length
;
4587 module
->next
= list
;
4589 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4591 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4598 /* We don't have a DMT section so this must be an object. Parse
4599 the module right now in order to compute its start address and
4601 module
= new_module (abfd
);
4602 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4609 /* Calculate and return the name of the source file and the line nearest
4610 to the wanted location in the specified module. */
4613 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4614 const char **file
, const char **func
,
4617 struct funcinfo
*funcinfo
;
4618 struct lineinfo
*lineinfo
;
4619 struct srecinfo
*srecinfo
;
4620 bfd_boolean ret
= FALSE
;
4622 /* Parse this module if that was not done at module creation. */
4623 if (! IS_MODULE_PARSED (module
))
4625 unsigned int size
= module
->size
;
4626 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4627 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4629 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4630 || bfd_bread (buffer
, size
, abfd
) != size
)
4632 bfd_set_error (bfd_error_no_debug_section
);
4636 parse_module (abfd
, module
, buffer
, size
);
4640 /* Find out the function (if any) that contains the address. */
4641 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4642 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4644 *func
= funcinfo
->name
;
4649 /* Find out the source file and the line nearest to the address. */
4650 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4651 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4653 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4654 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4656 if (srecinfo
->sfile
> 0)
4658 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4659 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4663 *file
= module
->name
;
4664 *line
= lineinfo
->line
;
4675 /* Provided a BFD, a section and an offset into the section, calculate and
4676 return the name of the source file and the line nearest to the wanted
4680 _bfd_vms_find_nearest_dst_line (bfd
*abfd
, asection
*section
,
4681 asymbol
**symbols ATTRIBUTE_UNUSED
,
4682 bfd_vma offset
, const char **file
,
4683 const char **func
, unsigned int *line
)
4685 struct module
*module
;
4687 /* What address are we looking for? */
4688 bfd_vma addr
= section
->vma
+ offset
;
4694 if (PRIV (dst_section
) == NULL
|| !(abfd
->flags
& (EXEC_P
| DYNAMIC
)))
4697 if (PRIV (modules
) == NULL
)
4699 PRIV (modules
) = build_module_list (abfd
);
4700 if (PRIV (modules
) == NULL
)
4704 for (module
= PRIV (modules
); module
; module
= module
->next
)
4705 if (addr
>= module
->low
&& addr
<= module
->high
)
4706 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4711 /* Canonicalizations. */
4712 /* Set name, value, section and flags of SYM from E. */
4715 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4724 flags
= BSF_NO_FLAGS
;
4730 if (e
->flags
& EGSY__V_WEAK
)
4733 if (e
->flags
& EGSY__V_DEF
)
4735 /* Symbol definition. */
4736 flags
|= BSF_GLOBAL
;
4737 if (e
->flags
& EGSY__V_NORM
)
4738 flags
|= BSF_FUNCTION
;
4744 /* Symbol reference. */
4745 sec
= bfd_und_section_ptr
;
4750 /* A universal symbol is by definition global... */
4751 flags
|= BSF_GLOBAL
;
4753 /* ...and dynamic in shared libraries. */
4754 if (abfd
->flags
& DYNAMIC
)
4755 flags
|= BSF_DYNAMIC
;
4757 if (e
->flags
& EGSY__V_WEAK
)
4760 if (!(e
->flags
& EGSY__V_DEF
))
4763 if (e
->flags
& EGSY__V_NORM
)
4764 flags
|= BSF_FUNCTION
;
4767 /* sec = e->section; */
4768 sec
= bfd_abs_section_ptr
;
4783 /* Return the number of bytes required to store a vector of pointers
4784 to asymbols for all the symbols in the BFD abfd, including a
4785 terminal NULL pointer. If there are no symbols in the BFD,
4786 then return 0. If an error occurs, return -1. */
4789 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4791 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4792 abfd
, PRIV (gsd_sym_count
)));
4794 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4797 /* Read the symbols from the BFD abfd, and fills in the vector
4798 location with pointers to the symbols and a trailing NULL.
4800 Return number of symbols read. */
4803 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4807 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4809 if (PRIV (csymbols
) == NULL
)
4811 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4812 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4814 /* Traverse table and fill symbols vector. */
4815 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4817 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4820 sym
= bfd_make_empty_symbol (abfd
);
4821 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4823 bfd_release (abfd
, PRIV (csymbols
));
4824 PRIV (csymbols
) = NULL
;
4828 PRIV (csymbols
)[i
] = sym
;
4832 if (symbols
!= NULL
)
4834 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4835 symbols
[i
] = PRIV (csymbols
)[i
];
4839 return PRIV (gsd_sym_count
);
4842 /* Read and convert relocations from ETIR. We do it once for all sections. */
4845 alpha_vms_slurp_relocs (bfd
*abfd
)
4849 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4851 /* We slurp relocs only once, for all sections. */
4852 if (PRIV (reloc_done
))
4854 PRIV (reloc_done
) = TRUE
;
4856 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4859 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4864 unsigned char *begin
;
4867 bfd_reloc_code_real_type reloc_code
;
4873 bfd_vma cur_address
;
4875 unsigned char *cur_sym
= NULL
;
4877 bfd_vma cur_addend
= 0;
4879 /* Skip non-ETIR records. */
4880 type
= _bfd_vms_get_object_record (abfd
);
4881 if (type
== EOBJ__C_EEOM
)
4883 if (type
!= EOBJ__C_ETIR
)
4886 begin
= PRIV (recrd
.rec
) + 4;
4887 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4889 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4893 cmd
= bfd_getl16 (ptr
);
4894 length
= bfd_getl16 (ptr
+ 2);
4896 cur_address
= vaddr
;
4898 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4899 _bfd_vms_etir_name (cmd
)));
4903 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4904 /* ALPHA_R_REFQUAD und_section, step 1 */
4909 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4910 cur_psidx
= bfd_getl32 (ptr
+ 4);
4911 cur_addend
= bfd_getl64 (ptr
+ 8);
4915 case ETIR__C_CTL_SETRB
:
4916 if (prev_cmd
!= ETIR__C_STA_PQ
)
4918 (*_bfd_error_handler
)
4919 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
4920 _bfd_vms_etir_name (cmd
));
4923 cur_psect
= cur_psidx
;
4929 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
4930 /* ALPHA_R_REFLONG und_section, step 2 */
4933 if (prev_cmd
!= ETIR__C_STA_GBL
)
4935 (*_bfd_error_handler
)
4936 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4937 _bfd_vms_etir_name (ETIR__C_STA_LW
));
4941 cur_addend
= bfd_getl32 (ptr
+ 4);
4945 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
4946 /* ALPHA_R_REFQUAD und_section, step 2 */
4947 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
4949 (*_bfd_error_handler
)
4950 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4951 _bfd_vms_etir_name (ETIR__C_STA_QW
));
4954 cur_addend
= bfd_getl64 (ptr
+ 4);
4958 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
4959 /* ALPHA_R_REFLONG abs_section, step 2 */
4960 /* ALPHA_R_REFLONG others, step 2 */
4961 if (prev_cmd
!= ETIR__C_OPR_ADD
4962 && prev_cmd
!= ETIR__C_STA_LW
4963 && prev_cmd
!= ETIR__C_STA_PQ
)
4965 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4966 _bfd_vms_etir_name (prev_cmd
),
4967 _bfd_vms_etir_name (ETIR__C_STO_LW
));
4970 reloc_code
= BFD_RELOC_32
;
4973 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
4974 /* ALPHA_R_REFQUAD abs_section, step 2 */
4975 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
4977 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4978 _bfd_vms_etir_name (prev_cmd
),
4979 _bfd_vms_etir_name (ETIR__C_STO_QW
));
4982 reloc_code
= BFD_RELOC_64
;
4985 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
4986 if (prev_cmd
!= ETIR__C_STA_PQ
)
4988 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4989 _bfd_vms_etir_name (prev_cmd
),
4990 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
4993 reloc_code
= BFD_RELOC_64
;
4996 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
4997 /* ALPHA_R_REFQUAD und_section, step 3 */
4998 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
5000 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
5001 _bfd_vms_etir_name (prev_cmd
),
5002 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
5005 prev_cmd
= ETIR__C_OPR_ADD
;
5008 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
5009 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
5013 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
5014 reloc_code
= BFD_RELOC_64
;
5018 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
5019 reloc_code
= BFD_RELOC_32
;
5023 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
5024 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
5028 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
5029 reloc_code
= BFD_RELOC_ALPHA_NOP
;
5032 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
5033 reloc_code
= BFD_RELOC_ALPHA_BSR
;
5036 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
5037 reloc_code
= BFD_RELOC_ALPHA_LDA
;
5040 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
5041 reloc_code
= BFD_RELOC_ALPHA_BOH
;
5045 cur_sym
= ptr
+ 4 + 32;
5046 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
5047 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
5050 case ETIR__C_STO_IMM
:
5051 vaddr
+= bfd_getl32 (ptr
+ 4);
5055 (*_bfd_error_handler
) (_("Unknown reloc %s"),
5056 _bfd_vms_etir_name (cmd
));
5062 struct vms_section_data_struct
*vms_sec
;
5065 /* Get section to which the relocation applies. */
5066 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
5068 (*_bfd_error_handler
) (_("Invalid section index in ETIR"));
5071 sec
= PRIV (sections
)[cur_psect
];
5072 vms_sec
= vms_section_data (sec
);
5074 /* Allocate a reloc entry. */
5075 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5077 if (vms_sec
->reloc_max
== 0)
5079 vms_sec
->reloc_max
= 64;
5080 sec
->relocation
= bfd_zmalloc
5081 (vms_sec
->reloc_max
* sizeof (arelent
));
5085 vms_sec
->reloc_max
*= 2;
5086 sec
->relocation
= bfd_realloc
5087 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5090 reloc
= &sec
->relocation
[sec
->reloc_count
];
5093 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5095 if (cur_sym
!= NULL
)
5098 unsigned int symlen
= *cur_sym
;
5101 /* Linear search. */
5106 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5107 if (PRIV (syms
)[j
]->namelen
== symlen
5108 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5110 sym
= &PRIV (csymbols
)[j
];
5115 (*_bfd_error_handler
) (_("Unknown symbol in command %s"),
5116 _bfd_vms_etir_name (cmd
));
5117 reloc
->sym_ptr_ptr
= NULL
;
5120 reloc
->sym_ptr_ptr
= sym
;
5122 else if (cur_psidx
>= 0)
5123 reloc
->sym_ptr_ptr
=
5124 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5126 reloc
->sym_ptr_ptr
= NULL
;
5128 reloc
->address
= cur_address
;
5129 reloc
->addend
= cur_addend
;
5131 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5140 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5145 /* Return the number of bytes required to store the relocation
5146 information associated with the given section. */
5149 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5151 alpha_vms_slurp_relocs (abfd
);
5153 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5156 /* Convert relocations from VMS (external) form into BFD internal
5157 form. Return the number of relocations. */
5160 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5161 asymbol
**symbols ATTRIBUTE_UNUSED
)
5166 if (!alpha_vms_slurp_relocs (abfd
))
5169 count
= section
->reloc_count
;
5170 tblptr
= section
->relocation
;
5173 *relptr
++ = tblptr
++;
5175 *relptr
= (arelent
*) NULL
;
5176 return section
->reloc_count
;
5179 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5181 /* How to process the various reloc types. */
5183 static bfd_reloc_status_type
5184 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5185 arelent
*reloc ATTRIBUTE_UNUSED
,
5186 asymbol
*sym ATTRIBUTE_UNUSED
,
5187 void * data ATTRIBUTE_UNUSED
,
5188 asection
*sec ATTRIBUTE_UNUSED
,
5189 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5190 char **error_message ATTRIBUTE_UNUSED
)
5193 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5194 vms_debug (2, "In section %s, symbol %s\n",
5195 sec
->name
, sym
->name
);
5196 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5197 reloc
->sym_ptr_ptr
[0]->name
,
5198 (unsigned long)reloc
->address
,
5199 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5200 vms_debug (2, "data at %p\n", data
);
5201 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5204 return bfd_reloc_ok
;
5207 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5208 from smaller values. Start with zero, widen, *then* decrement. */
5209 #define MINUS_ONE (((bfd_vma)0) - 1)
5211 static reloc_howto_type alpha_howto_table
[] =
5213 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5214 0, /* Rightshift. */
5215 0, /* Size (0 = byte, 1 = short, 2 = long). */
5217 TRUE
, /* PC relative. */
5219 complain_overflow_dont
,/* Complain_on_overflow. */
5220 reloc_nil
, /* Special_function. */
5221 "IGNORE", /* Name. */
5222 TRUE
, /* Partial_inplace. */
5223 0, /* Source mask */
5225 TRUE
), /* PC rel offset. */
5227 /* A 64 bit reference to a symbol. */
5228 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5229 0, /* Rightshift. */
5230 4, /* Size (0 = byte, 1 = short, 2 = long). */
5232 FALSE
, /* PC relative. */
5234 complain_overflow_bitfield
, /* Complain_on_overflow. */
5235 reloc_nil
, /* Special_function. */
5236 "REFQUAD", /* Name. */
5237 TRUE
, /* Partial_inplace. */
5238 MINUS_ONE
, /* Source mask. */
5239 MINUS_ONE
, /* Dest mask. */
5240 FALSE
), /* PC rel offset. */
5242 /* A 21 bit branch. The native assembler generates these for
5243 branches within the text segment, and also fills in the PC
5244 relative offset in the instruction. */
5245 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5246 2, /* Rightshift. */
5247 2, /* Size (0 = byte, 1 = short, 2 = long). */
5249 TRUE
, /* PC relative. */
5251 complain_overflow_signed
, /* Complain_on_overflow. */
5252 reloc_nil
, /* Special_function. */
5253 "BRADDR", /* Name. */
5254 TRUE
, /* Partial_inplace. */
5255 0x1fffff, /* Source mask. */
5256 0x1fffff, /* Dest mask. */
5257 FALSE
), /* PC rel offset. */
5259 /* A hint for a jump to a register. */
5260 HOWTO (ALPHA_R_HINT
, /* Type. */
5261 2, /* Rightshift. */
5262 1, /* Size (0 = byte, 1 = short, 2 = long). */
5264 TRUE
, /* PC relative. */
5266 complain_overflow_dont
,/* Complain_on_overflow. */
5267 reloc_nil
, /* Special_function. */
5269 TRUE
, /* Partial_inplace. */
5270 0x3fff, /* Source mask. */
5271 0x3fff, /* Dest mask. */
5272 FALSE
), /* PC rel offset. */
5274 /* 16 bit PC relative offset. */
5275 HOWTO (ALPHA_R_SREL16
, /* Type. */
5276 0, /* Rightshift. */
5277 1, /* Size (0 = byte, 1 = short, 2 = long). */
5279 TRUE
, /* PC relative. */
5281 complain_overflow_signed
, /* Complain_on_overflow. */
5282 reloc_nil
, /* Special_function. */
5283 "SREL16", /* Name. */
5284 TRUE
, /* Partial_inplace. */
5285 0xffff, /* Source mask. */
5286 0xffff, /* Dest mask. */
5287 FALSE
), /* PC rel offset. */
5289 /* 32 bit PC relative offset. */
5290 HOWTO (ALPHA_R_SREL32
, /* Type. */
5291 0, /* Rightshift. */
5292 2, /* Size (0 = byte, 1 = short, 2 = long). */
5294 TRUE
, /* PC relative. */
5296 complain_overflow_signed
, /* Complain_on_overflow. */
5297 reloc_nil
, /* Special_function. */
5298 "SREL32", /* Name. */
5299 TRUE
, /* Partial_inplace. */
5300 0xffffffff, /* Source mask. */
5301 0xffffffff, /* Dest mask. */
5302 FALSE
), /* PC rel offset. */
5304 /* A 64 bit PC relative offset. */
5305 HOWTO (ALPHA_R_SREL64
, /* Type. */
5306 0, /* Rightshift. */
5307 4, /* Size (0 = byte, 1 = short, 2 = long). */
5309 TRUE
, /* PC relative. */
5311 complain_overflow_signed
, /* Complain_on_overflow. */
5312 reloc_nil
, /* Special_function. */
5313 "SREL64", /* Name. */
5314 TRUE
, /* Partial_inplace. */
5315 MINUS_ONE
, /* Source mask. */
5316 MINUS_ONE
, /* Dest mask. */
5317 FALSE
), /* PC rel offset. */
5319 /* Push a value on the reloc evaluation stack. */
5320 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5321 0, /* Rightshift. */
5322 0, /* Size (0 = byte, 1 = short, 2 = long). */
5324 FALSE
, /* PC relative. */
5326 complain_overflow_dont
,/* Complain_on_overflow. */
5327 reloc_nil
, /* Special_function. */
5328 "OP_PUSH", /* Name. */
5329 FALSE
, /* Partial_inplace. */
5330 0, /* Source mask. */
5332 FALSE
), /* PC rel offset. */
5334 /* Store the value from the stack at the given address. Store it in
5335 a bitfield of size r_size starting at bit position r_offset. */
5336 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5337 0, /* Rightshift. */
5338 4, /* Size (0 = byte, 1 = short, 2 = long). */
5340 FALSE
, /* PC relative. */
5342 complain_overflow_dont
,/* Complain_on_overflow. */
5343 reloc_nil
, /* Special_function. */
5344 "OP_STORE", /* Name. */
5345 FALSE
, /* Partial_inplace. */
5346 0, /* Source mask. */
5347 MINUS_ONE
, /* Dest mask. */
5348 FALSE
), /* PC rel offset. */
5350 /* Subtract the reloc address from the value on the top of the
5351 relocation stack. */
5352 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5353 0, /* Rightshift. */
5354 0, /* Size (0 = byte, 1 = short, 2 = long). */
5356 FALSE
, /* PC relative. */
5358 complain_overflow_dont
,/* Complain_on_overflow. */
5359 reloc_nil
, /* Special_function. */
5360 "OP_PSUB", /* Name. */
5361 FALSE
, /* Partial_inplace. */
5362 0, /* Source mask. */
5364 FALSE
), /* PC rel offset. */
5366 /* Shift the value on the top of the relocation stack right by the
5368 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5369 0, /* Rightshift. */
5370 0, /* Size (0 = byte, 1 = short, 2 = long). */
5372 FALSE
, /* PC relative. */
5374 complain_overflow_dont
,/* Complain_on_overflow. */
5375 reloc_nil
, /* Special_function. */
5376 "OP_PRSHIFT", /* Name. */
5377 FALSE
, /* Partial_inplace. */
5378 0, /* Source mask. */
5380 FALSE
), /* PC rel offset. */
5382 /* Hack. Linkage is done by linker. */
5383 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5384 0, /* Rightshift. */
5385 8, /* Size (0 = byte, 1 = short, 2 = long). */
5387 FALSE
, /* PC relative. */
5389 complain_overflow_dont
,/* Complain_on_overflow. */
5390 reloc_nil
, /* Special_function. */
5391 "LINKAGE", /* Name. */
5392 FALSE
, /* Partial_inplace. */
5393 0, /* Source mask. */
5395 FALSE
), /* PC rel offset. */
5397 /* A 32 bit reference to a symbol. */
5398 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5399 0, /* Rightshift. */
5400 2, /* Size (0 = byte, 1 = short, 2 = long). */
5402 FALSE
, /* PC relative. */
5404 complain_overflow_bitfield
, /* Complain_on_overflow. */
5405 reloc_nil
, /* Special_function. */
5406 "REFLONG", /* Name. */
5407 TRUE
, /* Partial_inplace. */
5408 0xffffffff, /* Source mask. */
5409 0xffffffff, /* Dest mask. */
5410 FALSE
), /* PC rel offset. */
5412 /* A 64 bit reference to a procedure, written as 32 bit value. */
5413 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5414 0, /* Rightshift. */
5415 4, /* Size (0 = byte, 1 = short, 2 = long). */
5417 FALSE
, /* PC relative. */
5419 complain_overflow_signed
,/* Complain_on_overflow. */
5420 reloc_nil
, /* Special_function. */
5421 "CODEADDR", /* Name. */
5422 FALSE
, /* Partial_inplace. */
5423 0xffffffff, /* Source mask. */
5424 0xffffffff, /* Dest mask. */
5425 FALSE
), /* PC rel offset. */
5427 HOWTO (ALPHA_R_NOP
, /* Type. */
5428 0, /* Rightshift. */
5429 3, /* Size (0 = byte, 1 = short, 2 = long). */
5431 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5432 because the calculations for the 3 relocations are the same.
5433 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5434 TRUE
, /* PC relative. */
5436 complain_overflow_dont
,/* Complain_on_overflow. */
5437 reloc_nil
, /* Special_function. */
5439 FALSE
, /* Partial_inplace. */
5440 0xffffffff, /* Source mask. */
5441 0xffffffff, /* Dest mask. */
5442 FALSE
), /* PC rel offset. */
5444 HOWTO (ALPHA_R_BSR
, /* Type. */
5445 0, /* Rightshift. */
5446 3, /* Size (0 = byte, 1 = short, 2 = long). */
5448 TRUE
, /* PC relative. */
5450 complain_overflow_dont
,/* Complain_on_overflow. */
5451 reloc_nil
, /* Special_function. */
5453 FALSE
, /* Partial_inplace. */
5454 0xffffffff, /* Source mask. */
5455 0xffffffff, /* Dest mask. */
5456 FALSE
), /* PC rel offset. */
5458 HOWTO (ALPHA_R_LDA
, /* Type. */
5459 0, /* Rightshift. */
5460 3, /* Size (0 = byte, 1 = short, 2 = long). */
5462 FALSE
, /* PC relative. */
5464 complain_overflow_dont
,/* Complain_on_overflow. */
5465 reloc_nil
, /* Special_function. */
5467 FALSE
, /* Partial_inplace. */
5468 0xffffffff, /* Source mask. */
5469 0xffffffff, /* Dest mask. */
5470 FALSE
), /* PC rel offset. */
5472 HOWTO (ALPHA_R_BOH
, /* Type. */
5473 0, /* Rightshift. */
5474 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5476 TRUE
, /* PC relative. */
5478 complain_overflow_dont
,/* Complain_on_overflow. */
5479 reloc_nil
, /* Special_function. */
5481 FALSE
, /* Partial_inplace. */
5482 0xffffffff, /* Source mask. */
5483 0xffffffff, /* Dest mask. */
5484 FALSE
), /* PC rel offset. */
5487 /* Return a pointer to a howto structure which, when invoked, will perform
5488 the relocation code on data from the architecture noted. */
5490 static const struct reloc_howto_struct
*
5491 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5492 bfd_reloc_code_real_type code
)
5496 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5500 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5501 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5502 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5503 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5504 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5505 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5506 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5507 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5508 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5509 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5510 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5511 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5512 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5513 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5514 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5516 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
5519 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5520 return & alpha_howto_table
[alpha_type
];
5523 static reloc_howto_type
*
5524 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5530 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5532 if (alpha_howto_table
[i
].name
!= NULL
5533 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5534 return &alpha_howto_table
[i
];
5540 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5541 long symcount ATTRIBUTE_UNUSED
,
5542 asymbol
**usyms ATTRIBUTE_UNUSED
,
5543 long dynsymcount ATTRIBUTE_UNUSED
,
5544 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5551 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5556 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5558 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5569 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5576 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5578 value
= e
->code_value
;
5579 sec
= e
->code_section
;
5590 sname
= bfd_alloc (abfd
, l
+ 5);
5593 memcpy (sname
, name
, l
);
5594 memcpy (sname
+ l
, "..en", 5);
5601 sym
->udata
.p
= NULL
;
5610 vms_time_to_str (unsigned char *buf
)
5612 time_t t
= vms_rawtime_to_time_t (buf
);
5613 char *res
= ctime (&t
);
5616 res
= "*invalid time*";
5623 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5625 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5626 unsigned int subtype
;
5628 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5630 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5636 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5639 fprintf (file
, _("Module header\n"));
5640 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5641 fprintf (file
, _(" max record size: %u\n"),
5642 (unsigned)bfd_getl32 (mhd
->recsiz
));
5643 name
= (char *)(mhd
+ 1);
5644 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5645 name
+= name
[0] + 1;
5646 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5647 name
+= name
[0] + 1;
5648 fprintf (file
, _(" compile date : %.17s\n"), name
);
5653 fprintf (file
, _("Language Processor Name\n"));
5654 fprintf (file
, _(" language name: %.*s\n"),
5655 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5656 (char *)rec
+ sizeof (struct vms_emh_common
));
5661 fprintf (file
, _("Source Files Header\n"));
5662 fprintf (file
, _(" file: %.*s\n"),
5663 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5664 (char *)rec
+ sizeof (struct vms_emh_common
));
5669 fprintf (file
, _("Title Text Header\n"));
5670 fprintf (file
, _(" title: %.*s\n"),
5671 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5672 (char *)rec
+ sizeof (struct vms_emh_common
));
5677 fprintf (file
, _("Copyright Header\n"));
5678 fprintf (file
, _(" copyright: %.*s\n"),
5679 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5680 (char *)rec
+ sizeof (struct vms_emh_common
));
5684 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5690 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5692 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5694 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5695 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5696 (unsigned)bfd_getl32 (eeom
->total_lps
));
5697 fprintf (file
, _(" completion code: %u\n"),
5698 (unsigned)bfd_getl16 (eeom
->comcod
));
5701 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5702 fprintf (file
, _(" transfer addr psect: %u\n"),
5703 (unsigned)bfd_getl32 (eeom
->psindx
));
5704 fprintf (file
, _(" transfer address : 0x%08x\n"),
5705 (unsigned)bfd_getl32 (eeom
->tfradr
));
5710 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5712 if (flags
& EGSY__V_WEAK
)
5713 fputs (_(" WEAK"), file
);
5714 if (flags
& EGSY__V_DEF
)
5715 fputs (_(" DEF"), file
);
5716 if (flags
& EGSY__V_UNI
)
5717 fputs (_(" UNI"), file
);
5718 if (flags
& EGSY__V_REL
)
5719 fputs (_(" REL"), file
);
5720 if (flags
& EGSY__V_COMM
)
5721 fputs (_(" COMM"), file
);
5722 if (flags
& EGSY__V_VECEP
)
5723 fputs (_(" VECEP"), file
);
5724 if (flags
& EGSY__V_NORM
)
5725 fputs (_(" NORM"), file
);
5726 if (flags
& EGSY__V_QUAD_VAL
)
5727 fputs (_(" QVAL"), file
);
5731 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5733 if (flags
& EGPS__V_PIC
)
5734 fputs (_(" PIC"), file
);
5735 if (flags
& EGPS__V_LIB
)
5736 fputs (_(" LIB"), file
);
5737 if (flags
& EGPS__V_OVR
)
5738 fputs (_(" OVR"), file
);
5739 if (flags
& EGPS__V_REL
)
5740 fputs (_(" REL"), file
);
5741 if (flags
& EGPS__V_GBL
)
5742 fputs (_(" GBL"), file
);
5743 if (flags
& EGPS__V_SHR
)
5744 fputs (_(" SHR"), file
);
5745 if (flags
& EGPS__V_EXE
)
5746 fputs (_(" EXE"), file
);
5747 if (flags
& EGPS__V_RD
)
5748 fputs (_(" RD"), file
);
5749 if (flags
& EGPS__V_WRT
)
5750 fputs (_(" WRT"), file
);
5751 if (flags
& EGPS__V_VEC
)
5752 fputs (_(" VEC"), file
);
5753 if (flags
& EGPS__V_NOMOD
)
5754 fputs (_(" NOMOD"), file
);
5755 if (flags
& EGPS__V_COM
)
5756 fputs (_(" COM"), file
);
5757 if (flags
& EGPS__V_ALLOC_64BIT
)
5758 fputs (_(" 64B"), file
);
5762 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5764 unsigned int off
= sizeof (struct vms_egsd
);
5767 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5770 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5772 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5776 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5777 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5779 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5787 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5788 unsigned int flags
= bfd_getl16 (egps
->flags
);
5791 fprintf (file
, _("PSC - Program section definition\n"));
5792 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5793 fprintf (file
, _(" flags : 0x%04x"), flags
);
5794 evax_bfd_print_egsd_flags (file
, flags
);
5796 l
= bfd_getl32 (egps
->alloc
);
5797 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5798 fprintf (file
, _(" name : %.*s\n"),
5799 egps
->namlng
, egps
->name
);
5804 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5805 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5808 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5809 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5810 fprintf (file
, _(" flags : 0x%04x"), flags
);
5811 evax_bfd_print_egsd_flags (file
, flags
);
5813 l
= bfd_getl32 (esgps
->alloc
);
5814 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5815 fprintf (file
, _(" image offset : 0x%08x\n"),
5816 (unsigned int)bfd_getl32 (esgps
->base
));
5817 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5818 (unsigned int)bfd_getl32 (esgps
->value
));
5819 fprintf (file
, _(" name : %.*s\n"),
5820 esgps
->namlng
, esgps
->name
);
5825 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5826 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5828 if (flags
& EGSY__V_DEF
)
5830 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5832 fprintf (file
, _("SYM - Global symbol definition\n"));
5833 fprintf (file
, _(" flags: 0x%04x"), flags
);
5834 exav_bfd_print_egsy_flags (flags
, file
);
5836 fprintf (file
, _(" psect offset: 0x%08x\n"),
5837 (unsigned)bfd_getl32 (esdf
->value
));
5838 if (flags
& EGSY__V_NORM
)
5840 fprintf (file
, _(" code address: 0x%08x\n"),
5841 (unsigned)bfd_getl32 (esdf
->code_address
));
5842 fprintf (file
, _(" psect index for entry point : %u\n"),
5843 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5845 fprintf (file
, _(" psect index : %u\n"),
5846 (unsigned)bfd_getl32 (esdf
->psindx
));
5847 fprintf (file
, _(" name : %.*s\n"),
5848 esdf
->namlng
, esdf
->name
);
5852 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5854 fprintf (file
, _("SYM - Global symbol reference\n"));
5855 fprintf (file
, _(" name : %.*s\n"),
5856 esrf
->namlng
, esrf
->name
);
5862 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
5863 unsigned int flags
= bfd_getl32 (eidc
->flags
);
5866 fprintf (file
, _("IDC - Ident Consistency check\n"));
5867 fprintf (file
, _(" flags : 0x%08x"), flags
);
5868 if (flags
& EIDC__V_BINIDENT
)
5869 fputs (" BINDENT", file
);
5871 fprintf (file
, _(" id match : %x\n"),
5872 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
5873 fprintf (file
, _(" error severity: %x\n"),
5874 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
5876 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
5878 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
5880 if (flags
& EIDC__V_BINIDENT
)
5881 fprintf (file
, _(" binary ident : 0x%08x\n"),
5882 (unsigned)bfd_getl32 (p
+ 1));
5884 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
5889 struct vms_egst
*egst
= (struct vms_egst
*)e
;
5890 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
5892 fprintf (file
, _("SYMG - Universal symbol definition\n"));
5893 fprintf (file
, _(" flags: 0x%04x"), flags
);
5894 exav_bfd_print_egsy_flags (flags
, file
);
5896 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
5897 (unsigned)bfd_getl32 (egst
->value
));
5898 fprintf (file
, _(" entry point: 0x%08x\n"),
5899 (unsigned)bfd_getl32 (egst
->lp_1
));
5900 fprintf (file
, _(" proc descr : 0x%08x\n"),
5901 (unsigned)bfd_getl32 (egst
->lp_2
));
5902 fprintf (file
, _(" psect index: %u\n"),
5903 (unsigned)bfd_getl32 (egst
->psindx
));
5904 fprintf (file
, _(" name : %.*s\n"),
5905 egst
->namlng
, egst
->name
);
5910 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
5911 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
5913 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
5914 fprintf (file
, _(" flags: 0x%04x"), flags
);
5915 exav_bfd_print_egsy_flags (flags
, file
);
5917 fprintf (file
, _(" vector : 0x%08x\n"),
5918 (unsigned)bfd_getl32 (esdfv
->vector
));
5919 fprintf (file
, _(" psect offset: %u\n"),
5920 (unsigned)bfd_getl32 (esdfv
->value
));
5921 fprintf (file
, _(" psect index : %u\n"),
5922 (unsigned)bfd_getl32 (esdfv
->psindx
));
5923 fprintf (file
, _(" name : %.*s\n"),
5924 esdfv
->namlng
, esdfv
->name
);
5929 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
5930 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
5932 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
5933 fprintf (file
, _(" flags: 0x%04x"), flags
);
5934 exav_bfd_print_egsy_flags (flags
, file
);
5936 fprintf (file
, _(" version mask: 0x%08x\n"),
5937 (unsigned)bfd_getl32 (esdfm
->version_mask
));
5938 fprintf (file
, _(" psect offset: %u\n"),
5939 (unsigned)bfd_getl32 (esdfm
->value
));
5940 fprintf (file
, _(" psect index : %u\n"),
5941 (unsigned)bfd_getl32 (esdfm
->psindx
));
5942 fprintf (file
, _(" name : %.*s\n"),
5943 esdfm
->namlng
, esdfm
->name
);
5947 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
5955 evax_bfd_print_hex (FILE *file
, const char *pfx
,
5956 const unsigned char *buf
, unsigned int len
)
5962 for (i
= 0; i
< len
; i
++)
5966 fprintf (file
, " %02x", buf
[i
]);
5979 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
5981 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
5982 (unsigned)bfd_getl32 (buf
),
5983 (unsigned)bfd_getl32 (buf
+ 16));
5984 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
5985 (unsigned)bfd_getl32 (buf
+ 4),
5986 (unsigned)bfd_getl32 (buf
+ 12),
5987 (unsigned)bfd_getl32 (buf
+ 8));
5988 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
5989 (unsigned)bfd_getl32 (buf
+ 20),
5990 (unsigned)bfd_getl32 (buf
+ 28),
5991 (unsigned)bfd_getl32 (buf
+ 24));
5993 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
5994 (unsigned)bfd_getl32 (buf
+ 32),
5995 (unsigned)bfd_getl32 (buf
+ 40),
5996 (unsigned)bfd_getl32 (buf
+ 36));
5998 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
6002 evax_bfd_print_etir (FILE *file
, const char *name
,
6003 unsigned char *rec
, unsigned int rec_len
)
6005 unsigned int off
= sizeof (struct vms_egsd
);
6006 unsigned int sec_len
;
6008 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
6009 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
6010 (unsigned)sizeof (struct vms_eobjrec
));
6012 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
6014 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
6019 type
= bfd_getl16 (etir
->rectyp
);
6020 size
= bfd_getl16 (etir
->size
);
6021 buf
= rec
+ off
+ sizeof (struct vms_etir
);
6023 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
6026 case ETIR__C_STA_GBL
:
6027 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
6030 case ETIR__C_STA_LW
:
6031 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
6032 (unsigned)bfd_getl32 (buf
));
6034 case ETIR__C_STA_QW
:
6035 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
6036 (unsigned)bfd_getl32 (buf
+ 4),
6037 (unsigned)bfd_getl32 (buf
+ 0));
6039 case ETIR__C_STA_PQ
:
6040 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
6041 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
6042 (unsigned)bfd_getl32 (buf
+ 0),
6043 (unsigned)bfd_getl32 (buf
+ 8),
6044 (unsigned)bfd_getl32 (buf
+ 4));
6046 case ETIR__C_STA_LI
:
6047 fprintf (file
, _("STA_LI (stack literal)\n"));
6049 case ETIR__C_STA_MOD
:
6050 fprintf (file
, _("STA_MOD (stack module)\n"));
6052 case ETIR__C_STA_CKARG
:
6053 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
6057 fprintf (file
, _("STO_B (store byte)\n"));
6060 fprintf (file
, _("STO_W (store word)\n"));
6062 case ETIR__C_STO_LW
:
6063 fprintf (file
, _("STO_LW (store longword)\n"));
6065 case ETIR__C_STO_QW
:
6066 fprintf (file
, _("STO_QW (store quadword)\n"));
6068 case ETIR__C_STO_IMMR
:
6070 unsigned int len
= bfd_getl32 (buf
);
6072 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6074 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6078 case ETIR__C_STO_GBL
:
6079 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6082 case ETIR__C_STO_CA
:
6083 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6086 case ETIR__C_STO_RB
:
6087 fprintf (file
, _("STO_RB (store relative branch)\n"));
6089 case ETIR__C_STO_AB
:
6090 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6092 case ETIR__C_STO_OFF
:
6093 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6095 case ETIR__C_STO_IMM
:
6097 unsigned int len
= bfd_getl32 (buf
);
6099 _("STO_IMM (store immediate) %u bytes\n"),
6101 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6105 case ETIR__C_STO_GBL_LW
:
6106 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6109 case ETIR__C_STO_LP_PSB
:
6110 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6112 case ETIR__C_STO_HINT_GBL
:
6113 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6115 case ETIR__C_STO_HINT_PS
:
6116 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6119 case ETIR__C_OPR_NOP
:
6120 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6122 case ETIR__C_OPR_ADD
:
6123 fprintf (file
, _("OPR_ADD (add)\n"));
6125 case ETIR__C_OPR_SUB
:
6126 fprintf (file
, _("OPR_SUB (substract)\n"));
6128 case ETIR__C_OPR_MUL
:
6129 fprintf (file
, _("OPR_MUL (multiply)\n"));
6131 case ETIR__C_OPR_DIV
:
6132 fprintf (file
, _("OPR_DIV (divide)\n"));
6134 case ETIR__C_OPR_AND
:
6135 fprintf (file
, _("OPR_AND (logical and)\n"));
6137 case ETIR__C_OPR_IOR
:
6138 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6140 case ETIR__C_OPR_EOR
:
6141 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6143 case ETIR__C_OPR_NEG
:
6144 fprintf (file
, _("OPR_NEG (negate)\n"));
6146 case ETIR__C_OPR_COM
:
6147 fprintf (file
, _("OPR_COM (complement)\n"));
6149 case ETIR__C_OPR_INSV
:
6150 fprintf (file
, _("OPR_INSV (insert field)\n"));
6152 case ETIR__C_OPR_ASH
:
6153 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6155 case ETIR__C_OPR_USH
:
6156 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6158 case ETIR__C_OPR_ROT
:
6159 fprintf (file
, _("OPR_ROT (rotate)\n"));
6161 case ETIR__C_OPR_SEL
:
6162 fprintf (file
, _("OPR_SEL (select)\n"));
6164 case ETIR__C_OPR_REDEF
:
6165 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6167 case ETIR__C_OPR_DFLIT
:
6168 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6171 case ETIR__C_STC_LP
:
6172 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6174 case ETIR__C_STC_LP_PSB
:
6176 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6177 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6178 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6179 buf
+= 4 + 1 + buf
[4];
6180 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6182 case ETIR__C_STC_GBL
:
6183 fprintf (file
, _("STC_GBL (store cond global)\n"));
6184 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6185 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6187 case ETIR__C_STC_GCA
:
6188 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6189 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6190 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6192 case ETIR__C_STC_PS
:
6193 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6195 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6196 (unsigned)bfd_getl32 (buf
),
6197 (unsigned)bfd_getl32 (buf
+ 4),
6198 (unsigned)bfd_getl32 (buf
+ 12),
6199 (unsigned)bfd_getl32 (buf
+ 8));
6201 case ETIR__C_STC_NOP_GBL
:
6202 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6203 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6205 case ETIR__C_STC_NOP_PS
:
6206 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6207 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6209 case ETIR__C_STC_BSR_GBL
:
6210 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6211 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6213 case ETIR__C_STC_BSR_PS
:
6214 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6215 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6217 case ETIR__C_STC_LDA_GBL
:
6218 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6219 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6221 case ETIR__C_STC_LDA_PS
:
6222 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6223 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6225 case ETIR__C_STC_BOH_GBL
:
6226 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6227 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6229 case ETIR__C_STC_BOH_PS
:
6230 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6231 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6233 case ETIR__C_STC_NBH_GBL
:
6235 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6237 case ETIR__C_STC_NBH_PS
:
6239 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6242 case ETIR__C_CTL_SETRB
:
6243 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6246 case ETIR__C_CTL_AUGRB
:
6248 unsigned int val
= bfd_getl32 (buf
);
6249 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6252 case ETIR__C_CTL_DFLOC
:
6253 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6255 case ETIR__C_CTL_STLOC
:
6256 fprintf (file
, _("CTL_STLOC (set location)\n"));
6258 case ETIR__C_CTL_STKDL
:
6259 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6262 fprintf (file
, _("*unhandled*\n"));
6270 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6272 bfd_boolean is_first
= TRUE
;
6273 bfd_boolean has_records
= FALSE
;
6277 unsigned int rec_len
;
6278 unsigned int pad_len
;
6280 unsigned int hdr_size
;
6285 unsigned char buf
[6];
6290 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6292 fprintf (file
, _("cannot read GST record length\n"));
6295 rec_len
= bfd_getl16 (buf
+ 0);
6296 if (rec_len
== bfd_getl16 (buf
+ 4)
6297 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6299 /* The format is raw: record-size, type, record-size. */
6301 pad_len
= (rec_len
+ 1) & ~1U;
6304 else if (rec_len
== EOBJ__C_EMH
)
6306 has_records
= FALSE
;
6307 pad_len
= bfd_getl16 (buf
+ 2);
6313 fprintf (file
, _("cannot find EMH in first GST record\n"));
6316 rec
= bfd_malloc (pad_len
);
6317 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6321 unsigned int rec_len2
= 0;
6322 unsigned char hdr
[4];
6326 unsigned char buf_len
[2];
6328 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6329 != sizeof (buf_len
))
6331 fprintf (file
, _("cannot read GST record length\n"));
6334 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6337 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6339 fprintf (file
, _("cannot read GST record header\n"));
6342 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6344 pad_len
= (rec_len
+ 1) & ~1U;
6347 rec
= bfd_malloc (pad_len
);
6348 memcpy (rec
, hdr
, sizeof (hdr
));
6349 hdr_size
= sizeof (hdr
);
6350 if (has_records
&& rec_len2
!= rec_len
)
6352 fprintf (file
, _(" corrupted GST\n"));
6357 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6358 != pad_len
- hdr_size
)
6360 fprintf (file
, _("cannot read GST record\n"));
6364 type
= (unsigned)bfd_getl16 (rec
);
6369 evax_bfd_print_emh (file
, rec
, rec_len
);
6372 evax_bfd_print_egsd (file
, rec
, rec_len
);
6375 evax_bfd_print_eeom (file
, rec
, rec_len
);
6380 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6383 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6386 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6389 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6397 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6398 unsigned int stride
)
6406 count
= bfd_getl32 (rel
+ 0);
6410 base
= bfd_getl32 (rel
+ 4);
6412 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6416 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6422 val
= bfd_getl32 (rel
);
6425 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6427 for (k
= 0; k
< 32; k
++)
6432 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6447 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6454 count
= bfd_getl32 (rel
+ 0);
6457 fprintf (file
, _(" image %u (%u entries)\n"),
6458 (unsigned)bfd_getl32 (rel
+ 4), count
);
6460 for (j
= 0; j
< count
; j
++)
6462 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6463 (unsigned)bfd_getl32 (rel
+ 0),
6464 (unsigned)bfd_getl32 (rel
+ 4));
6471 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6480 count
= bfd_getl32 (rel
+ 0);
6483 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6484 (unsigned)bfd_getl32 (rel
+ 4), count
);
6486 for (j
= 0; j
< count
; j
++)
6490 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6505 evax_bfd_print_indent (int indent
, FILE *file
)
6507 for (; indent
; indent
--)
6512 evax_bfd_get_dsc_name (unsigned int v
)
6516 case DSC__K_DTYPE_Z
:
6517 return "Z (Unspecified)";
6518 case DSC__K_DTYPE_V
:
6520 case DSC__K_DTYPE_BU
:
6521 return "BU (Byte logical)";
6522 case DSC__K_DTYPE_WU
:
6523 return "WU (Word logical)";
6524 case DSC__K_DTYPE_LU
:
6525 return "LU (Longword logical)";
6526 case DSC__K_DTYPE_QU
:
6527 return "QU (Quadword logical)";
6528 case DSC__K_DTYPE_B
:
6529 return "B (Byte integer)";
6530 case DSC__K_DTYPE_W
:
6531 return "W (Word integer)";
6532 case DSC__K_DTYPE_L
:
6533 return "L (Longword integer)";
6534 case DSC__K_DTYPE_Q
:
6535 return "Q (Quadword integer)";
6536 case DSC__K_DTYPE_F
:
6537 return "F (Single-precision floating)";
6538 case DSC__K_DTYPE_D
:
6539 return "D (Double-precision floating)";
6540 case DSC__K_DTYPE_FC
:
6541 return "FC (Complex)";
6542 case DSC__K_DTYPE_DC
:
6543 return "DC (Double-precision Complex)";
6544 case DSC__K_DTYPE_T
:
6545 return "T (ASCII text string)";
6546 case DSC__K_DTYPE_NU
:
6547 return "NU (Numeric string, unsigned)";
6548 case DSC__K_DTYPE_NL
:
6549 return "NL (Numeric string, left separate sign)";
6550 case DSC__K_DTYPE_NLO
:
6551 return "NLO (Numeric string, left overpunched sign)";
6552 case DSC__K_DTYPE_NR
:
6553 return "NR (Numeric string, right separate sign)";
6554 case DSC__K_DTYPE_NRO
:
6555 return "NRO (Numeric string, right overpunched sig)";
6556 case DSC__K_DTYPE_NZ
:
6557 return "NZ (Numeric string, zoned sign)";
6558 case DSC__K_DTYPE_P
:
6559 return "P (Packed decimal string)";
6560 case DSC__K_DTYPE_ZI
:
6561 return "ZI (Sequence of instructions)";
6562 case DSC__K_DTYPE_ZEM
:
6563 return "ZEM (Procedure entry mask)";
6564 case DSC__K_DTYPE_DSC
:
6565 return "DSC (Descriptor, used for arrays of dyn strings)";
6566 case DSC__K_DTYPE_OU
:
6567 return "OU (Octaword logical)";
6568 case DSC__K_DTYPE_O
:
6569 return "O (Octaword integer)";
6570 case DSC__K_DTYPE_G
:
6571 return "G (Double precision G floating, 64 bit)";
6572 case DSC__K_DTYPE_H
:
6573 return "H (Quadruple precision floating, 128 bit)";
6574 case DSC__K_DTYPE_GC
:
6575 return "GC (Double precision complex, G floating)";
6576 case DSC__K_DTYPE_HC
:
6577 return "HC (Quadruple precision complex, H floating)";
6578 case DSC__K_DTYPE_CIT
:
6579 return "CIT (COBOL intermediate temporary)";
6580 case DSC__K_DTYPE_BPV
:
6581 return "BPV (Bound Procedure Value)";
6582 case DSC__K_DTYPE_BLV
:
6583 return "BLV (Bound Label Value)";
6584 case DSC__K_DTYPE_VU
:
6585 return "VU (Bit Unaligned)";
6586 case DSC__K_DTYPE_ADT
:
6587 return "ADT (Absolute Date-Time)";
6588 case DSC__K_DTYPE_VT
:
6589 return "VT (Varying Text)";
6590 case DSC__K_DTYPE_T2
:
6591 return "T2 (16-bit char)";
6592 case DSC__K_DTYPE_VT2
:
6593 return "VT2 (16-bit varying char)";
6595 return "?? (unknown)";
6600 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6602 unsigned char bclass
= buf
[3];
6603 unsigned char dtype
= buf
[2];
6604 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6605 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6607 evax_bfd_print_indent (indent
, file
);
6609 if (len
== 1 && pointer
== 0xffffffffUL
)
6612 fprintf (file
, _("64 bits *unhandled*\n"));
6616 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6617 bclass
, dtype
, len
, pointer
);
6620 case DSC__K_CLASS_NCA
:
6622 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6624 const unsigned char *b
;
6626 evax_bfd_print_indent (indent
, file
);
6627 fprintf (file
, _("non-contiguous array of %s\n"),
6628 evax_bfd_get_dsc_name (dsc
->dtype
));
6629 evax_bfd_print_indent (indent
+ 1, file
);
6631 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6632 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6633 evax_bfd_print_indent (indent
+ 1, file
);
6635 _("arsize: %u, a0: 0x%08x\n"),
6636 (unsigned)bfd_getl32 (dsc
->arsize
),
6637 (unsigned)bfd_getl32 (dsc
->a0
));
6638 evax_bfd_print_indent (indent
+ 1, file
);
6639 fprintf (file
, _("Strides:\n"));
6640 b
= buf
+ sizeof (*dsc
);
6641 for (i
= 0; i
< dsc
->dimct
; i
++)
6643 evax_bfd_print_indent (indent
+ 2, file
);
6644 fprintf (file
, _("[%u]: %u\n"), i
+ 1,
6645 (unsigned)bfd_getl32 (b
));
6648 evax_bfd_print_indent (indent
+ 1, file
);
6649 fprintf (file
, _("Bounds:\n"));
6650 b
= buf
+ sizeof (*dsc
);
6651 for (i
= 0; i
< dsc
->dimct
; i
++)
6653 evax_bfd_print_indent (indent
+ 2, file
);
6654 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6655 (unsigned)bfd_getl32 (b
+ 0),
6656 (unsigned)bfd_getl32 (b
+ 4));
6661 case DSC__K_CLASS_UBS
:
6663 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6665 evax_bfd_print_indent (indent
, file
);
6666 fprintf (file
, _("unaligned bit-string of %s\n"),
6667 evax_bfd_get_dsc_name (ubs
->dtype
));
6668 evax_bfd_print_indent (indent
+ 1, file
);
6670 _("base: %u, pos: %u\n"),
6671 (unsigned)bfd_getl32 (ubs
->base
),
6672 (unsigned)bfd_getl32 (ubs
->pos
));
6676 fprintf (file
, _("*unhandled*\n"));
6683 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6685 unsigned int vflags
= buf
[0];
6686 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6687 unsigned int len
= 5;
6689 evax_bfd_print_indent (indent
, file
);
6690 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6695 case DST__K_VFLAGS_NOVAL
:
6696 fprintf (file
, _("(no value)\n"));
6698 case DST__K_VFLAGS_NOTACTIVE
:
6699 fprintf (file
, _("(not active)\n"));
6701 case DST__K_VFLAGS_UNALLOC
:
6702 fprintf (file
, _("(not allocated)\n"));
6704 case DST__K_VFLAGS_DSC
:
6705 fprintf (file
, _("(descriptor)\n"));
6706 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6708 case DST__K_VFLAGS_TVS
:
6709 fprintf (file
, _("(trailing value)\n"));
6711 case DST__K_VS_FOLLOWS
:
6712 fprintf (file
, _("(value spec follows)\n"));
6714 case DST__K_VFLAGS_BITOFFS
:
6715 fprintf (file
, _("(at bit offset %u)\n"), value
);
6718 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6719 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6720 vflags
& DST__K_DISP
? 1 : 0,
6721 vflags
& DST__K_INDIR
? 1 : 0);
6722 switch (vflags
& DST__K_VALKIND_MASK
)
6724 case DST__K_VALKIND_LITERAL
:
6725 fputs (_("literal"), file
);
6727 case DST__K_VALKIND_ADDR
:
6728 fputs (_("address"), file
);
6730 case DST__K_VALKIND_DESC
:
6731 fputs (_("desc"), file
);
6733 case DST__K_VALKIND_REG
:
6734 fputs (_("reg"), file
);
6737 fputs (")\n", file
);
6744 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6746 unsigned char kind
= buf
[2];
6747 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6749 evax_bfd_print_indent (indent
, file
);
6750 fprintf (file
, ("len: %2u, kind: %2u "), len
, kind
);
6754 case DST__K_TS_ATOM
:
6755 fprintf (file
, ("atomic, type=0x%02x %s\n"),
6756 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6759 fprintf (file
, ("indirect, defined at 0x%08x\n"),
6760 (unsigned)bfd_getl32 (buf
));
6762 case DST__K_TS_TPTR
:
6763 fprintf (file
, ("typed pointer\n"));
6764 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6767 fprintf (file
, ("pointer\n"));
6769 case DST__K_TS_ARRAY
:
6771 const unsigned char *vs
;
6772 unsigned int vec_len
;
6775 fprintf (file
, ("array, dim: %u, bitmap: "), buf
[0]);
6776 vec_len
= (buf
[0] + 1 + 7) / 8;
6777 for (i
= 0; i
< vec_len
; i
++)
6778 fprintf (file
, " %02x", buf
[i
+ 1]);
6780 vs
= buf
+ 1 + vec_len
;
6781 evax_bfd_print_indent (indent
, file
);
6782 fprintf (file
, ("array descriptor:\n"));
6783 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6784 for (i
= 0; i
< buf
[0] + 1U; i
++)
6785 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6787 evax_bfd_print_indent (indent
, file
);
6789 fprintf (file
, ("type spec for element:\n"));
6791 fprintf (file
, ("type spec for subscript %u:\n"), i
);
6792 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6793 vs
+= bfd_getl16 (vs
);
6798 fprintf (file
, ("*unhandled*\n"));
6803 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6805 unsigned int off
= 0;
6806 unsigned int pc
= 0;
6807 unsigned int line
= 0;
6809 fprintf (file
, _("Debug symbol table:\n"));
6811 while (dst_size
> 0)
6813 struct vms_dst_header dsth
;
6818 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6820 fprintf (file
, _("cannot read DST header\n"));
6823 len
= bfd_getl16 (dsth
.length
);
6824 type
= bfd_getl16 (dsth
.type
);
6825 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
6835 len
-= sizeof (dsth
);
6836 buf
= bfd_malloc (len
);
6837 if (bfd_bread (buf
, len
, abfd
) != len
)
6839 fprintf (file
, _("cannot read DST symbol\n"));
6844 case DSC__K_DTYPE_V
:
6845 case DSC__K_DTYPE_BU
:
6846 case DSC__K_DTYPE_WU
:
6847 case DSC__K_DTYPE_LU
:
6848 case DSC__K_DTYPE_QU
:
6849 case DSC__K_DTYPE_B
:
6850 case DSC__K_DTYPE_W
:
6851 case DSC__K_DTYPE_L
:
6852 case DSC__K_DTYPE_Q
:
6853 case DSC__K_DTYPE_F
:
6854 case DSC__K_DTYPE_D
:
6855 case DSC__K_DTYPE_FC
:
6856 case DSC__K_DTYPE_DC
:
6857 case DSC__K_DTYPE_T
:
6858 case DSC__K_DTYPE_NU
:
6859 case DSC__K_DTYPE_NL
:
6860 case DSC__K_DTYPE_NLO
:
6861 case DSC__K_DTYPE_NR
:
6862 case DSC__K_DTYPE_NRO
:
6863 case DSC__K_DTYPE_NZ
:
6864 case DSC__K_DTYPE_P
:
6865 case DSC__K_DTYPE_ZI
:
6866 case DSC__K_DTYPE_ZEM
:
6867 case DSC__K_DTYPE_DSC
:
6868 case DSC__K_DTYPE_OU
:
6869 case DSC__K_DTYPE_O
:
6870 case DSC__K_DTYPE_G
:
6871 case DSC__K_DTYPE_H
:
6872 case DSC__K_DTYPE_GC
:
6873 case DSC__K_DTYPE_HC
:
6874 case DSC__K_DTYPE_CIT
:
6875 case DSC__K_DTYPE_BPV
:
6876 case DSC__K_DTYPE_BLV
:
6877 case DSC__K_DTYPE_VU
:
6878 case DSC__K_DTYPE_ADT
:
6879 case DSC__K_DTYPE_VT
:
6880 case DSC__K_DTYPE_T2
:
6881 case DSC__K_DTYPE_VT2
:
6882 fprintf (file
, _("standard data: %s\n"),
6883 evax_bfd_get_dsc_name (type
));
6884 evax_bfd_print_valspec (buf
, 4, file
);
6885 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
6889 struct vms_dst_modbeg
*dst
= (void *)buf
;
6890 const char *name
= (const char *)buf
+ sizeof (*dst
);
6892 fprintf (file
, _("modbeg\n"));
6893 fprintf (file
, _(" flags: %d, language: %u, "
6894 "major: %u, minor: %u\n"),
6896 (unsigned)bfd_getl32 (dst
->language
),
6897 (unsigned)bfd_getl16 (dst
->major
),
6898 (unsigned)bfd_getl16 (dst
->minor
));
6899 fprintf (file
, _(" module name: %.*s\n"),
6901 name
+= name
[0] + 1;
6902 fprintf (file
, _(" compiler : %.*s\n"),
6907 fprintf (file
, _("modend\n"));
6911 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
6912 const char *name
= (const char *)buf
+ sizeof (*dst
);
6914 fputs (_("rtnbeg\n"), file
);
6915 fprintf (file
, _(" flags: %u, address: 0x%08x, "
6916 "pd-address: 0x%08x\n"),
6918 (unsigned)bfd_getl32 (dst
->address
),
6919 (unsigned)bfd_getl32 (dst
->pd_address
));
6920 fprintf (file
, _(" routine name: %.*s\n"),
6926 struct vms_dst_rtnend
*dst
= (void *)buf
;
6928 fprintf (file
, _("rtnend: size 0x%08x\n"),
6929 (unsigned)bfd_getl32 (dst
->size
));
6934 struct vms_dst_prolog
*dst
= (void *)buf
;
6936 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
6937 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
6942 struct vms_dst_epilog
*dst
= (void *)buf
;
6944 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
6945 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
6950 struct vms_dst_blkbeg
*dst
= (void *)buf
;
6951 const char *name
= (const char *)buf
+ sizeof (*dst
);
6953 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6954 (unsigned)bfd_getl32 (dst
->address
),
6960 struct vms_dst_blkend
*dst
= (void *)buf
;
6962 fprintf (file
, _("blkend: size: 0x%08x\n"),
6963 (unsigned)bfd_getl32 (dst
->size
));
6966 case DST__K_TYPSPEC
:
6968 fprintf (file
, _("typspec (len: %u)\n"), len
);
6969 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
6970 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
6975 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
6976 evax_bfd_print_valspec (buf
, 4, file
);
6981 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
6982 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
6984 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
6985 evax_bfd_print_valspec (buf
, 4, file
);
6986 fprintf (file
, (" len: %u bits\n"),
6987 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
6991 fprintf (file
, _("recend\n"));
6993 case DST__K_ENUMBEG
:
6994 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
6995 buf
[0], buf
[1], buf
+ 2);
6997 case DST__K_ENUMELT
:
6998 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
6999 evax_bfd_print_valspec (buf
, 4, file
);
7001 case DST__K_ENUMEND
:
7002 fprintf (file
, _("enumend\n"));
7006 struct vms_dst_label
*lab
= (void *)buf
;
7007 fprintf (file
, ("label, name: %.*s\n"),
7008 lab
->name
[0], lab
->name
+ 1);
7009 fprintf (file
, (" address: 0x%08x\n"),
7010 (unsigned)bfd_getl32 (lab
->value
));
7013 case DST__K_DIS_RANGE
:
7015 unsigned int cnt
= bfd_getl32 (buf
);
7016 unsigned char *rng
= buf
+ 4;
7019 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
7020 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
7021 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
7022 (unsigned)bfd_getl32 (rng
),
7023 (unsigned)bfd_getl32 (rng
+ 4));
7027 case DST__K_LINE_NUM
:
7029 unsigned char *buf_orig
= buf
;
7031 fprintf (file
, _("line num (len: %u)\n"), len
);
7036 unsigned char cmdlen
;
7046 case DST__K_DELTA_PC_W
:
7047 val
= bfd_getl16 (buf
+ 1);
7048 fprintf (file
, _("delta_pc_w %u\n"), val
);
7053 case DST__K_INCR_LINUM
:
7055 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
7059 case DST__K_INCR_LINUM_W
:
7060 val
= bfd_getl16 (buf
+ 1);
7061 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
7065 case DST__K_INCR_LINUM_L
:
7066 val
= bfd_getl32 (buf
+ 1);
7067 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
7071 case DST__K_SET_LINUM
:
7072 line
= bfd_getl16 (buf
+ 1);
7073 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7076 case DST__K_SET_LINUM_B
:
7078 fprintf (file
, _("set_line_num_b %u\n"), line
);
7081 case DST__K_SET_LINUM_L
:
7082 line
= bfd_getl32 (buf
+ 1);
7083 fprintf (file
, _("set_line_num_l %u\n"), line
);
7086 case DST__K_SET_ABS_PC
:
7087 pc
= bfd_getl32 (buf
+ 1);
7088 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7091 case DST__K_DELTA_PC_L
:
7092 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7093 (unsigned)bfd_getl32 (buf
+ 1));
7097 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7099 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7103 val
= bfd_getl16 (buf
+ 1);
7104 fprintf (file
, _("term_w: 0x%04x"), val
);
7106 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7112 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7113 line
++; /* FIXME: curr increment. */
7115 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7120 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7133 unsigned char *buf_orig
= buf
;
7135 fprintf (file
, _("source (len: %u)\n"), len
);
7139 signed char cmd
= buf
[0];
7140 unsigned char cmdlen
= 0;
7144 case DST__K_SRC_DECLFILE
:
7146 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7149 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7151 src
->length
, src
->flags
,
7152 (unsigned)bfd_getl16 (src
->fileid
));
7153 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7154 "ebk: 0x%08x, ffb: 0x%04x, "
7156 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7157 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7158 (unsigned)bfd_getl32 (src
->rms_ebk
),
7159 (unsigned)bfd_getl16 (src
->rms_ffb
),
7161 name
= (const char *)buf
+ 1 + sizeof (*src
);
7162 fprintf (file
, _(" filename : %.*s\n"),
7164 name
+= name
[0] + 1;
7165 fprintf (file
, _(" module name: %.*s\n"),
7167 cmdlen
= 2 + src
->length
;
7170 case DST__K_SRC_SETFILE
:
7171 fprintf (file
, _(" setfile %u\n"),
7172 (unsigned)bfd_getl16 (buf
+ 1));
7175 case DST__K_SRC_SETREC_W
:
7176 fprintf (file
, _(" setrec %u\n"),
7177 (unsigned)bfd_getl16 (buf
+ 1));
7180 case DST__K_SRC_SETREC_L
:
7181 fprintf (file
, _(" setrec %u\n"),
7182 (unsigned)bfd_getl32 (buf
+ 1));
7185 case DST__K_SRC_SETLNUM_W
:
7186 fprintf (file
, _(" setlnum %u\n"),
7187 (unsigned)bfd_getl16 (buf
+ 1));
7190 case DST__K_SRC_SETLNUM_L
:
7191 fprintf (file
, _(" setlnum %u\n"),
7192 (unsigned)bfd_getl32 (buf
+ 1));
7195 case DST__K_SRC_DEFLINES_W
:
7196 fprintf (file
, _(" deflines %u\n"),
7197 (unsigned)bfd_getl16 (buf
+ 1));
7200 case DST__K_SRC_DEFLINES_B
:
7201 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7204 case DST__K_SRC_FORMFEED
:
7205 fprintf (file
, _(" formfeed\n"));
7209 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7221 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7229 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7231 struct vms_eihd eihd
;
7234 unsigned int eiha_off
;
7235 unsigned int eihi_off
;
7236 unsigned int eihs_off
;
7237 unsigned int eisd_off
;
7238 unsigned int eihef_off
= 0;
7239 unsigned int eihnp_off
= 0;
7240 unsigned int dmt_vbn
= 0;
7241 unsigned int dmt_size
= 0;
7242 unsigned int dst_vbn
= 0;
7243 unsigned int dst_size
= 0;
7244 unsigned int gst_vbn
= 0;
7245 unsigned int gst_size
= 0;
7246 unsigned int eiaf_vbn
= 0;
7247 unsigned int eiaf_size
= 0;
7248 unsigned int eihvn_off
;
7250 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7251 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7253 fprintf (file
, _("cannot read EIHD\n"));
7256 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7257 (unsigned)bfd_getl32 (eihd
.size
),
7258 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7259 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7260 (unsigned)bfd_getl32 (eihd
.majorid
),
7261 (unsigned)bfd_getl32 (eihd
.minorid
));
7263 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7267 name
= _("executable");
7270 name
= _("linkable image");
7273 name
= _("unknown");
7276 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7278 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7281 case EIHD__C_NATIVE
:
7288 name
= _("unknown");
7291 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7293 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7294 eiha_off
= bfd_getl32 (eihd
.activoff
);
7295 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7296 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7297 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7298 "imgid: %u, patch: %u\n"),
7299 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7300 (unsigned)bfd_getl32 (eihd
.patchoff
));
7301 fprintf (file
, _(" fixup info rva: "));
7302 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7303 fprintf (file
, _(", symbol vector rva: "));
7304 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7305 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7306 fprintf (file
, _("\n"
7307 " version array off: %u\n"),
7310 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7311 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7312 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7313 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7314 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7315 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7316 fprintf (file
, _(" linker flags: %08x:"), val
);
7317 if (val
& EIHD__M_LNKDEBUG
)
7318 fprintf (file
, " LNKDEBUG");
7319 if (val
& EIHD__M_LNKNOTFR
)
7320 fprintf (file
, " LNKNOTFR");
7321 if (val
& EIHD__M_NOP0BUFS
)
7322 fprintf (file
, " NOP0BUFS");
7323 if (val
& EIHD__M_PICIMG
)
7324 fprintf (file
, " PICIMG");
7325 if (val
& EIHD__M_P0IMAGE
)
7326 fprintf (file
, " P0IMAGE");
7327 if (val
& EIHD__M_DBGDMT
)
7328 fprintf (file
, " DBGDMT");
7329 if (val
& EIHD__M_INISHR
)
7330 fprintf (file
, " INISHR");
7331 if (val
& EIHD__M_XLATED
)
7332 fprintf (file
, " XLATED");
7333 if (val
& EIHD__M_BIND_CODE_SEC
)
7334 fprintf (file
, " BIND_CODE_SEC");
7335 if (val
& EIHD__M_BIND_DATA_SEC
)
7336 fprintf (file
, " BIND_DATA_SEC");
7337 if (val
& EIHD__M_MKTHREADS
)
7338 fprintf (file
, " MKTHREADS");
7339 if (val
& EIHD__M_UPCALLS
)
7340 fprintf (file
, " UPCALLS");
7341 if (val
& EIHD__M_OMV_READY
)
7342 fprintf (file
, " OMV_READY");
7343 if (val
& EIHD__M_EXT_BIND_SECT
)
7344 fprintf (file
, " EXT_BIND_SECT");
7345 fprintf (file
, "\n");
7346 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7347 "match ctrl: %u, symvect_size: %u\n"),
7348 (unsigned)bfd_getl32 (eihd
.ident
),
7349 (unsigned)bfd_getl32 (eihd
.sysver
),
7351 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7352 fprintf (file
, _(" BPAGE: %u"),
7353 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7354 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7356 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7357 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7358 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7359 eihef_off
, eihnp_off
);
7361 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7365 struct vms_eihvn eihvn
;
7369 fprintf (file
, _("system version array information:\n"));
7370 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7371 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7373 fprintf (file
, _("cannot read EIHVN header\n"));
7376 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7377 for (j
= 0; j
< 32; j
++)
7378 if (mask
& (1 << j
))
7380 struct vms_eihvn_subversion ver
;
7381 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7383 fprintf (file
, _("cannot read EIHVN version\n"));
7386 fprintf (file
, _(" %02u "), j
);
7389 case EIHVN__BASE_IMAGE_BIT
:
7390 fputs (_("BASE_IMAGE "), file
);
7392 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7393 fputs (_("MEMORY_MANAGEMENT"), file
);
7396 fputs (_("IO "), file
);
7398 case EIHVN__FILES_VOLUMES_BIT
:
7399 fputs (_("FILES_VOLUMES "), file
);
7401 case EIHVN__PROCESS_SCHED_BIT
:
7402 fputs (_("PROCESS_SCHED "), file
);
7404 case EIHVN__SYSGEN_BIT
:
7405 fputs (_("SYSGEN "), file
);
7407 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7408 fputs (_("CLUSTERS_LOCKMGR "), file
);
7410 case EIHVN__LOGICAL_NAMES_BIT
:
7411 fputs (_("LOGICAL_NAMES "), file
);
7413 case EIHVN__SECURITY_BIT
:
7414 fputs (_("SECURITY "), file
);
7416 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7417 fputs (_("IMAGE_ACTIVATOR "), file
);
7419 case EIHVN__NETWORKS_BIT
:
7420 fputs (_("NETWORKS "), file
);
7422 case EIHVN__COUNTERS_BIT
:
7423 fputs (_("COUNTERS "), file
);
7425 case EIHVN__STABLE_BIT
:
7426 fputs (_("STABLE "), file
);
7428 case EIHVN__MISC_BIT
:
7429 fputs (_("MISC "), file
);
7431 case EIHVN__CPU_BIT
:
7432 fputs (_("CPU "), file
);
7434 case EIHVN__VOLATILE_BIT
:
7435 fputs (_("VOLATILE "), file
);
7437 case EIHVN__SHELL_BIT
:
7438 fputs (_("SHELL "), file
);
7440 case EIHVN__POSIX_BIT
:
7441 fputs (_("POSIX "), file
);
7443 case EIHVN__MULTI_PROCESSING_BIT
:
7444 fputs (_("MULTI_PROCESSING "), file
);
7446 case EIHVN__GALAXY_BIT
:
7447 fputs (_("GALAXY "), file
);
7450 fputs (_("*unknown* "), file
);
7453 fprintf (file
, _(": %u.%u\n"),
7454 (unsigned)bfd_getl16 (ver
.major
),
7455 (unsigned)bfd_getl16 (ver
.minor
));
7461 struct vms_eiha eiha
;
7463 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7464 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7466 fprintf (file
, _("cannot read EIHA\n"));
7469 fprintf (file
, _("Image activation: (size=%u)\n"),
7470 (unsigned)bfd_getl32 (eiha
.size
));
7471 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7472 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7473 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7474 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7475 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7476 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7477 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7478 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7479 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7480 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7481 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7482 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7483 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7484 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7485 (unsigned)bfd_getl32 (eiha
.inishr
));
7489 struct vms_eihi eihi
;
7491 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7492 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7494 fprintf (file
, _("cannot read EIHI\n"));
7497 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7498 (unsigned)bfd_getl32 (eihi
.majorid
),
7499 (unsigned)bfd_getl32 (eihi
.minorid
));
7500 fprintf (file
, _(" image name : %.*s\n"),
7501 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7502 fprintf (file
, _(" link time : %s\n"),
7503 vms_time_to_str (eihi
.linktime
));
7504 fprintf (file
, _(" image ident : %.*s\n"),
7505 eihi
.imgid
[0], eihi
.imgid
+ 1);
7506 fprintf (file
, _(" linker ident : %.*s\n"),
7507 eihi
.linkid
[0], eihi
.linkid
+ 1);
7508 fprintf (file
, _(" image build ident: %.*s\n"),
7509 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7513 struct vms_eihs eihs
;
7515 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7516 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7518 fprintf (file
, _("cannot read EIHS\n"));
7521 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7522 (unsigned)bfd_getl32 (eihs
.majorid
),
7523 (unsigned)bfd_getl32 (eihs
.minorid
));
7524 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7525 dst_size
= bfd_getl32 (eihs
.dstsize
);
7526 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7527 dst_vbn
, dst_size
, dst_size
);
7528 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7529 gst_size
= bfd_getl32 (eihs
.gstsize
);
7530 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7532 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7533 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7534 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7537 while (eisd_off
!= 0)
7539 struct vms_eisd eisd
;
7544 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7545 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7547 fprintf (file
, _("cannot read EISD\n"));
7550 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7551 if (len
!= (unsigned)-1)
7555 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7557 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7558 "size: %u, offset: %u)\n"),
7559 (unsigned)bfd_getl32 (eisd
.majorid
),
7560 (unsigned)bfd_getl32 (eisd
.minorid
),
7564 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7565 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7566 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7567 (unsigned)bfd_getl32 (eisd
.secsize
));
7568 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7569 fprintf (file
, _(" flags: 0x%04x"), val
);
7570 if (val
& EISD__M_GBL
)
7571 fprintf (file
, " GBL");
7572 if (val
& EISD__M_CRF
)
7573 fprintf (file
, " CRF");
7574 if (val
& EISD__M_DZRO
)
7575 fprintf (file
, " DZRO");
7576 if (val
& EISD__M_WRT
)
7577 fprintf (file
, " WRT");
7578 if (val
& EISD__M_INITALCODE
)
7579 fprintf (file
, " INITALCODE");
7580 if (val
& EISD__M_BASED
)
7581 fprintf (file
, " BASED");
7582 if (val
& EISD__M_FIXUPVEC
)
7583 fprintf (file
, " FIXUPVEC");
7584 if (val
& EISD__M_RESIDENT
)
7585 fprintf (file
, " RESIDENT");
7586 if (val
& EISD__M_VECTOR
)
7587 fprintf (file
, " VECTOR");
7588 if (val
& EISD__M_PROTECT
)
7589 fprintf (file
, " PROTECT");
7590 if (val
& EISD__M_LASTCLU
)
7591 fprintf (file
, " LASTCLU");
7592 if (val
& EISD__M_EXE
)
7593 fprintf (file
, " EXE");
7594 if (val
& EISD__M_NONSHRADR
)
7595 fprintf (file
, " NONSHRADR");
7596 if (val
& EISD__M_QUAD_LENGTH
)
7597 fprintf (file
, " QUAD_LENGTH");
7598 if (val
& EISD__M_ALLOC_64BIT
)
7599 fprintf (file
, " ALLOC_64BIT");
7600 fprintf (file
, "\n");
7601 if (val
& EISD__M_FIXUPVEC
)
7603 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7604 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7606 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7607 (unsigned)bfd_getl32 (eisd
.vbn
),
7608 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7611 case EISD__K_NORMAL
:
7612 fputs (_("NORMAL"), file
);
7614 case EISD__K_SHRFXD
:
7615 fputs (_("SHRFXD"), file
);
7617 case EISD__K_PRVFXD
:
7618 fputs (_("PRVFXD"), file
);
7620 case EISD__K_SHRPIC
:
7621 fputs (_("SHRPIC"), file
);
7623 case EISD__K_PRVPIC
:
7624 fputs (_("PRVPIC"), file
);
7626 case EISD__K_USRSTACK
:
7627 fputs (_("USRSTACK"), file
);
7630 fputs (_("*unknown*"), file
);
7633 fputs (_(")\n"), file
);
7634 if (val
& EISD__M_GBL
)
7635 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7636 (unsigned)bfd_getl32 (eisd
.ident
),
7637 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7643 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7645 fprintf (file
, _("cannot read DMT\n"));
7649 fprintf (file
, _("Debug module table:\n"));
7651 while (dmt_size
> 0)
7653 struct vms_dmt_header dmth
;
7656 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7658 fprintf (file
, _("cannot read DMT header\n"));
7661 count
= bfd_getl16 (dmth
.psect_count
);
7663 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7664 (unsigned)bfd_getl32 (dmth
.modbeg
),
7665 (unsigned)bfd_getl32 (dmth
.size
), count
);
7666 dmt_size
-= sizeof (dmth
);
7669 struct vms_dmt_psect dmtp
;
7671 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7673 fprintf (file
, _("cannot read DMT psect\n"));
7676 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7677 (unsigned)bfd_getl32 (dmtp
.start
),
7678 (unsigned)bfd_getl32 (dmtp
.length
));
7680 dmt_size
-= sizeof (dmtp
);
7687 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7689 fprintf (file
, _("cannot read DST\n"));
7693 evax_bfd_print_dst (abfd
, dst_size
, file
);
7697 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7699 fprintf (file
, _("cannot read GST\n"));
7703 fprintf (file
, _("Global symbol table:\n"));
7704 evax_bfd_print_eobj (abfd
, file
);
7709 struct vms_eiaf
*eiaf
;
7710 unsigned int qrelfixoff
;
7711 unsigned int lrelfixoff
;
7712 unsigned int qdotadroff
;
7713 unsigned int ldotadroff
;
7714 unsigned int shrimgcnt
;
7715 unsigned int shlstoff
;
7716 unsigned int codeadroff
;
7717 unsigned int lpfixoff
;
7718 unsigned int chgprtoff
;
7720 buf
= bfd_malloc (eiaf_size
);
7722 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7723 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7725 fprintf (file
, _("cannot read EIHA\n"));
7729 eiaf
= (struct vms_eiaf
*)buf
;
7731 _("Image activator fixup: (major: %u, minor: %u)\n"),
7732 (unsigned)bfd_getl32 (eiaf
->majorid
),
7733 (unsigned)bfd_getl32 (eiaf
->minorid
));
7734 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7735 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7736 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7737 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7738 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7739 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7740 fprintf (file
, _(" size : %u\n"),
7741 (unsigned)bfd_getl32 (eiaf
->size
));
7742 fprintf (file
, _(" flags: 0x%08x\n"),
7743 (unsigned)bfd_getl32 (eiaf
->flags
));
7744 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7745 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7746 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7747 qrelfixoff
, lrelfixoff
);
7748 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7749 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7750 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7751 qdotadroff
, ldotadroff
);
7752 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7753 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7754 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7755 codeadroff
, lpfixoff
);
7756 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7757 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7758 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7759 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7760 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7761 shlstoff
, shrimgcnt
);
7762 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7763 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7764 (unsigned)bfd_getl32 (eiaf
->permctx
));
7765 fprintf (file
, _(" base_va : 0x%08x\n"),
7766 (unsigned)bfd_getl32 (eiaf
->base_va
));
7767 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7768 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7772 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7775 fprintf (file
, _(" Shareable images:\n"));
7776 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7779 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7780 j
, shl
->size
, shl
->flags
,
7781 shl
->imgnam
[0], shl
->imgnam
+ 1);
7784 if (qrelfixoff
!= 0)
7786 fprintf (file
, _(" quad-word relocation fixups:\n"));
7787 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7789 if (lrelfixoff
!= 0)
7791 fprintf (file
, _(" long-word relocation fixups:\n"));
7792 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
7794 if (qdotadroff
!= 0)
7796 fprintf (file
, _(" quad-word .address reference fixups:\n"));
7797 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
7799 if (ldotadroff
!= 0)
7801 fprintf (file
, _(" long-word .address reference fixups:\n"));
7802 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
7804 if (codeadroff
!= 0)
7806 fprintf (file
, _(" Code Address Reference Fixups:\n"));
7807 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
7811 fprintf (file
, _(" Linkage Pairs Referece Fixups:\n"));
7812 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
7816 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
7817 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
7820 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
7821 for (j
= 0; j
< count
; j
++, eicp
++)
7823 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
7825 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7826 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
7827 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
7828 (unsigned)bfd_getl32 (eicp
->size
),
7829 (unsigned)bfd_getl32 (eicp
->newprt
));
7833 fprintf (file
, "NA");
7835 case PRT__C_RESERVED
:
7836 fprintf (file
, "RES");
7839 fprintf (file
, "KW");
7842 fprintf (file
, "KR");
7845 fprintf (file
, "UW");
7848 fprintf (file
, "EW");
7851 fprintf (file
, "ERKW");
7854 fprintf (file
, "ER");
7857 fprintf (file
, "SW");
7860 fprintf (file
, "SREW");
7863 fprintf (file
, "SRKW");
7866 fprintf (file
, "SR");
7869 fprintf (file
, "URSW");
7872 fprintf (file
, "UREW");
7875 fprintf (file
, "URKW");
7878 fprintf (file
, "UR");
7892 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
7894 FILE *file
= (FILE *)ptr
;
7896 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
7897 evax_bfd_print_image (abfd
, file
);
7900 if (bfd_seek (abfd
, 0, SEEK_SET
))
7902 evax_bfd_print_eobj (abfd
, file
);
7909 /* Slurp ETIR/EDBG/ETBT VMS object records. */
7912 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
7914 asection
*cur_section
;
7915 file_ptr cur_offset
;
7916 asection
*dst_section
;
7917 file_ptr dst_offset
;
7919 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
7925 dst_section
= PRIV (dst_section
);
7929 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
7931 /* Discard the DST section. */
7935 else if (dst_section
)
7937 dst_offset
= dst_section
->output_offset
;
7938 dst_section
= dst_section
->output_section
;
7947 type
= _bfd_vms_get_object_record (abfd
);
7950 vms_debug2 ((2, "next_record failed\n"));
7956 PRIV (image_section
) = cur_section
;
7957 PRIV (image_offset
) = cur_offset
;
7958 res
= _bfd_vms_slurp_etir (abfd
, info
);
7959 cur_section
= PRIV (image_section
);
7960 cur_offset
= PRIV (image_offset
);
7964 if (dst_section
== NULL
)
7966 PRIV (image_section
) = dst_section
;
7967 PRIV (image_offset
) = dst_offset
;
7968 res
= _bfd_vms_slurp_etir (abfd
, info
);
7969 dst_offset
= PRIV (image_offset
);
7978 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
7985 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
7986 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7991 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
7994 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7996 struct alpha_vms_shlib_el
*sl
;
7997 asection
*sect
= PRIV2 (src
, image_section
);
7998 file_ptr offset
= PRIV2 (src
, image_offset
);
8000 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8001 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8002 sl
->has_fixups
= TRUE
;
8003 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
8004 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8008 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
8010 struct alpha_vms_shlib_el
*sl
;
8011 asection
*sect
= PRIV2 (src
, image_section
);
8012 file_ptr offset
= PRIV2 (src
, image_offset
);
8014 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8015 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8016 sl
->has_fixups
= TRUE
;
8017 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
8018 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
8022 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
8023 bfd
*shlib
, bfd_vma vec
)
8025 struct alpha_vms_shlib_el
*sl
;
8026 struct alpha_vms_vma_ref
*r
;
8027 asection
*sect
= PRIV2 (src
, image_section
);
8028 file_ptr offset
= PRIV2 (src
, image_offset
);
8030 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
8031 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
8032 sl
->has_fixups
= TRUE
;
8033 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
8034 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
8039 alpha_vms_add_lw_fixup (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8040 unsigned int shr ATTRIBUTE_UNUSED
,
8041 bfd_vma vec ATTRIBUTE_UNUSED
)
8048 alpha_vms_add_qw_fixup (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
8049 unsigned int shr ATTRIBUTE_UNUSED
,
8050 bfd_vma vec ATTRIBUTE_UNUSED
)
8057 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8062 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
8066 static struct bfd_hash_entry
*
8067 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
8068 struct bfd_hash_table
*table
,
8071 struct alpha_vms_link_hash_entry
*ret
=
8072 (struct alpha_vms_link_hash_entry
*) entry
;
8074 /* Allocate the structure if it has not already been allocated by a
8077 ret
= ((struct alpha_vms_link_hash_entry
*)
8078 bfd_hash_allocate (table
,
8079 sizeof (struct alpha_vms_link_hash_entry
)));
8083 /* Call the allocation method of the superclass. */
8084 ret
= ((struct alpha_vms_link_hash_entry
*)
8085 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8090 return (struct bfd_hash_entry
*) ret
;
8093 /* Create an Alpha/VMS link hash table. */
8095 static struct bfd_link_hash_table
*
8096 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8098 struct alpha_vms_link_hash_table
*ret
;
8099 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8101 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8104 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8105 alpha_vms_link_hash_newfunc
,
8106 sizeof (struct alpha_vms_link_hash_entry
)))
8112 VEC_INIT (ret
->shrlibs
);
8119 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8123 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8125 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8126 struct alpha_vms_link_hash_entry
*h
;
8127 struct bfd_link_hash_entry
*h_root
;
8130 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8133 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8135 /* In selective_search mode, only add definition that are
8137 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8138 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8139 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8145 h_root
= (struct bfd_link_hash_entry
*) h
;
8146 if (_bfd_generic_link_add_one_symbol
8147 (info
, abfd
, sym
.name
, sym
.flags
, sym
.section
, sym
.value
,
8148 NULL
, FALSE
, FALSE
, &h_root
) == FALSE
)
8150 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8152 if ((e
->flags
& EGSY__V_DEF
)
8154 && abfd
->xvec
== info
->output_bfd
->xvec
)
8158 if (abfd
->flags
& DYNAMIC
)
8160 struct alpha_vms_shlib_el
*shlib
;
8162 /* We do not want to include any of the sections in a dynamic
8163 object in the output file. See comment in elflink.c. */
8164 bfd_section_list_clear (abfd
);
8166 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8167 struct alpha_vms_shlib_el
);
8169 VEC_INIT (shlib
->ca
);
8170 VEC_INIT (shlib
->lp
);
8171 VEC_INIT (shlib
->qr
);
8172 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8179 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8182 struct bfd_link_hash_entry
**pundef
;
8183 struct bfd_link_hash_entry
**next_pundef
;
8185 /* We only accept VMS libraries. */
8186 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8188 bfd_set_error (bfd_error_wrong_format
);
8192 /* The archive_pass field in the archive itself is used to
8193 initialize PASS, since we may search the same archive multiple
8195 pass
= ++abfd
->archive_pass
;
8197 /* Look through the list of undefined symbols. */
8198 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8200 struct bfd_link_hash_entry
*h
;
8206 next_pundef
= &(*pundef
)->u
.undef
.next
;
8208 /* When a symbol is defined, it is not necessarily removed from
8210 if (h
->type
!= bfd_link_hash_undefined
8211 && h
->type
!= bfd_link_hash_common
)
8213 /* Remove this entry from the list, for general cleanliness
8214 and because we are going to look through the list again
8215 if we search any more libraries. We can't remove the
8216 entry if it is the tail, because that would lose any
8217 entries we add to the list later on. */
8218 if (*pundef
!= info
->hash
->undefs_tail
)
8220 *pundef
= *next_pundef
;
8221 next_pundef
= pundef
;
8226 /* Look for this symbol in the archive hash table. */
8227 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8228 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8230 /* Nothing in this slot. */
8234 element
= bfd_get_elt_at_index (abfd
, symidx
);
8235 if (element
== NULL
)
8238 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8241 if (! bfd_check_format (element
, bfd_object
))
8243 element
->archive_pass
= -1;
8247 orig_element
= element
;
8248 if (bfd_is_thin_archive (abfd
))
8250 element
= _bfd_vms_lib_get_imagelib_file (element
);
8251 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8253 orig_element
->archive_pass
= -1;
8258 /* Unlike the generic linker, we know that this element provides
8259 a definition for an undefined symbol and we know that we want
8260 to include it. We don't need to check anything. */
8261 if (! (*info
->callbacks
->add_archive_element
) (info
, element
,
8264 if (! alpha_vms_link_add_object_symbols (element
, info
))
8267 orig_element
->archive_pass
= pass
;
8274 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8276 switch (bfd_get_format (abfd
))
8279 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8281 return alpha_vms_link_add_object_symbols (abfd
, info
);
8284 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8286 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8289 bfd_set_error (bfd_error_wrong_format
);
8295 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8297 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8298 unsigned char *content
;
8300 unsigned int sz
= 0;
8301 unsigned int lp_sz
= 0;
8302 unsigned int ca_sz
= 0;
8303 unsigned int qr_sz
= 0;
8304 unsigned int shrimg_cnt
= 0;
8305 struct vms_eiaf
*eiaf
;
8309 /* Shared libraries. */
8310 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8312 struct alpha_vms_shlib_el
*shlib
;
8314 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8316 if (!shlib
->has_fixups
)
8321 if (VEC_COUNT (shlib
->ca
) > 0)
8323 /* Header + entries. */
8325 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8327 if (VEC_COUNT (shlib
->lp
) > 0)
8329 /* Header + entries. */
8331 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8333 if (VEC_COUNT (shlib
->qr
) > 0)
8335 /* Header + entries. */
8337 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8348 /* Finish now if there is no content. */
8349 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8352 /* Allocate section content (round-up size) */
8353 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8354 + ca_sz
+ lp_sz
+ qr_sz
;
8355 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8356 content
= bfd_zalloc (info
->output_bfd
, sz
);
8357 if (content
== NULL
)
8360 sec
= alpha_vms_link_hash (info
)->fixup
;
8361 sec
->contents
= content
;
8364 eiaf
= (struct vms_eiaf
*)content
;
8365 off
= sizeof (struct vms_eiaf
);
8366 bfd_putl32 (0, eiaf
->majorid
);
8367 bfd_putl32 (0, eiaf
->minorid
);
8368 bfd_putl32 (0, eiaf
->iaflink
);
8369 bfd_putl32 (0, eiaf
->fixuplnk
);
8370 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8371 bfd_putl32 (0, eiaf
->flags
);
8372 bfd_putl32 (0, eiaf
->qrelfixoff
);
8373 bfd_putl32 (0, eiaf
->lrelfixoff
);
8374 bfd_putl32 (0, eiaf
->qdotadroff
);
8375 bfd_putl32 (0, eiaf
->ldotadroff
);
8376 bfd_putl32 (0, eiaf
->codeadroff
);
8377 bfd_putl32 (0, eiaf
->lpfixoff
);
8378 bfd_putl32 (0, eiaf
->chgprtoff
);
8379 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8380 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8381 bfd_putl32 (0, eiaf
->shlextra
);
8382 bfd_putl32 (0, eiaf
->permctx
);
8383 bfd_putl32 (0, eiaf
->base_va
);
8384 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8391 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8393 struct alpha_vms_shlib_el
*shlib
;
8394 struct vms_shl
*shl
;
8396 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8398 if (!shlib
->has_fixups
)
8401 /* Renumber shared images. */
8402 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8404 shl
= (struct vms_shl
*)(content
+ off
);
8405 bfd_putl32 (0, shl
->baseva
);
8406 bfd_putl32 (0, shl
->shlptr
);
8407 bfd_putl32 (0, shl
->ident
);
8408 bfd_putl32 (0, shl
->permctx
);
8409 shl
->size
= sizeof (struct vms_shl
);
8410 bfd_putl16 (0, shl
->fill_1
);
8412 bfd_putl32 (0, shl
->icb
);
8413 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8414 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8417 off
+= sizeof (struct vms_shl
);
8423 bfd_putl32 (off
, eiaf
->codeadroff
);
8425 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8427 struct alpha_vms_shlib_el
*shlib
;
8430 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8432 if (VEC_COUNT (shlib
->ca
) == 0)
8435 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8436 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8439 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8441 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8447 bfd_putl32 (0, content
+ off
);
8448 bfd_putl32 (0, content
+ off
+ 4);
8455 bfd_putl32 (off
, eiaf
->lpfixoff
);
8457 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8459 struct alpha_vms_shlib_el
*shlib
;
8462 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8464 if (VEC_COUNT (shlib
->lp
) == 0)
8467 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8468 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8471 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8473 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8479 bfd_putl32 (0, content
+ off
);
8480 bfd_putl32 (0, content
+ off
+ 4);
8487 bfd_putl32 (off
, eiaf
->qdotadroff
);
8489 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8491 struct alpha_vms_shlib_el
*shlib
;
8494 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8496 if (VEC_COUNT (shlib
->qr
) == 0)
8499 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8500 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8503 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8505 struct alpha_vms_vma_ref
*r
;
8506 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8507 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8508 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8513 bfd_putl32 (0, content
+ off
);
8514 bfd_putl32 (0, content
+ off
+ 4);
8524 /* Called by bfd_link_hash_traverse to fill the symbol table.
8525 Return FALSE in case of failure. */
8528 alpha_vms_link_output_symbol (struct bfd_link_hash_entry
*hc
, void *infov
)
8530 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8531 struct alpha_vms_link_hash_entry
*h
= (struct alpha_vms_link_hash_entry
*)hc
;
8532 struct vms_symbol_entry
*sym
;
8534 switch (h
->root
.type
)
8536 case bfd_link_hash_new
:
8537 case bfd_link_hash_undefined
:
8539 case bfd_link_hash_undefweak
:
8541 case bfd_link_hash_defined
:
8542 case bfd_link_hash_defweak
:
8544 asection
*sec
= h
->root
.u
.def
.section
;
8546 /* FIXME: this is certainly a symbol from a dynamic library. */
8547 if (bfd_is_abs_section (sec
))
8550 if (sec
->owner
->flags
& DYNAMIC
)
8554 case bfd_link_hash_common
:
8556 case bfd_link_hash_indirect
:
8557 case bfd_link_hash_warning
:
8561 /* Do not write not kept symbols. */
8562 if (info
->strip
== strip_some
8563 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8564 FALSE
, FALSE
) != NULL
)
8569 /* This symbol doesn't come from a VMS object. So we suppose it is
8571 int len
= strlen (h
->root
.root
.string
);
8573 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8574 sizeof (*sym
) + len
);
8578 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8580 sym
->owner
= info
->output_bfd
;
8582 sym
->typ
= EGSD__C_SYMG
;
8584 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8585 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8586 sym
->section
= h
->root
.u
.def
.section
;
8587 sym
->value
= h
->root
.u
.def
.value
;
8592 if (!add_symbol_entry (info
->output_bfd
, sym
))
8599 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8602 struct bfd_link_order
*p
;
8610 bfd_get_outsymbols (abfd
) = NULL
;
8611 bfd_get_symcount (abfd
) = 0;
8613 /* Mark all sections which will be included in the output file. */
8614 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8615 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8616 if (p
->type
== bfd_indirect_link_order
)
8617 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8620 /* Handle all the link order information for the sections. */
8621 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8623 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8624 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8626 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8628 printf (" at 0x%08x - 0x%08x: ",
8629 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8632 case bfd_section_reloc_link_order
:
8633 case bfd_symbol_reloc_link_order
:
8634 printf (" section/symbol reloc\n");
8636 case bfd_indirect_link_order
:
8637 printf (" section %s of %s\n",
8638 p
->u
.indirect
.section
->name
,
8639 p
->u
.indirect
.section
->owner
->filename
);
8641 case bfd_data_link_order
:
8642 printf (" explicit data\n");
8645 printf (" *unknown* type %u\n", p
->type
);
8652 /* Generate the symbol table. */
8653 BFD_ASSERT (PRIV (syms
) == NULL
);
8654 if (info
->strip
!= strip_all
)
8655 bfd_link_hash_traverse (info
->hash
, alpha_vms_link_output_symbol
, info
);
8657 /* Find the entry point. */
8658 if (bfd_get_start_address (abfd
) == 0)
8660 bfd
*startbfd
= NULL
;
8662 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8664 /* Consider only VMS object files. */
8665 if (sub
->xvec
!= abfd
->xvec
)
8668 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8670 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8672 if (startbfd
!= NULL
8673 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8675 (*info
->callbacks
->einfo
)
8676 (_("%P: multiple entry points: in modules %B and %B\n"),
8685 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8686 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8689 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8691 bfd_set_start_address
8692 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8696 /* Set transfer addresses. */
8699 struct bfd_link_hash_entry
*h
;
8702 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
8703 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
8704 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
8705 PRIV (transfer_address
[i
++]) =
8706 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
8707 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
8709 PRIV (transfer_address
[i
++]) = 0;
8712 /* Allocate contents. */
8713 base_addr
= (bfd_vma
)-1;
8715 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8717 if (o
->flags
& SEC_HAS_CONTENTS
)
8719 o
->contents
= bfd_alloc (abfd
, o
->size
);
8720 if (o
->contents
== NULL
)
8723 if (o
->flags
& SEC_LOAD
)
8725 if (o
->vma
< base_addr
)
8727 if (o
->vma
+ o
->size
> last_addr
)
8728 last_addr
= o
->vma
+ o
->size
;
8732 /* Create the fixup section. */
8733 fixupsec
= bfd_make_section_anyway_with_flags
8734 (info
->output_bfd
, "$FIXUP$",
8735 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8736 if (fixupsec
== NULL
)
8738 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
8739 fixupsec
->vma
= last_addr
;
8741 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
8742 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
8744 /* Create the DMT section, if necessary. */
8745 BFD_ASSERT (PRIV (dst_section
) == NULL
);
8746 dst
= bfd_get_section_by_name (abfd
, "$DST$");
8747 if (dst
!= NULL
&& dst
->size
== 0)
8751 PRIV (dst_section
) = dst
;
8752 dmt
= bfd_make_section_anyway_with_flags
8753 (info
->output_bfd
, "$DMT$",
8754 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8761 /* Read all sections from the inputs. */
8762 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8764 if (sub
->flags
& DYNAMIC
)
8766 alpha_vms_create_eisd_for_shared (abfd
, sub
);
8770 if (!alpha_vms_read_sections_content (sub
, info
))
8774 /* Handle all the link order information for the sections.
8775 Note: past this point, it is not possible to create new sections. */
8776 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8778 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8782 case bfd_section_reloc_link_order
:
8783 case bfd_symbol_reloc_link_order
:
8786 case bfd_indirect_link_order
:
8790 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
8797 /* Compute fixups. */
8798 if (!alpha_vms_build_fixups (info
))
8801 /* Compute the DMT. */
8805 unsigned char *contents
= NULL
;
8807 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
8808 for (pass
= 0; pass
< 2; pass
++)
8810 unsigned int off
= 0;
8812 /* For each object file (ie for each module). */
8813 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8816 struct vms_dmt_header
*dmth
= NULL
;
8817 unsigned int psect_count
;
8819 /* Skip this module if it has no DST. */
8820 sub_dst
= PRIV2 (sub
, dst_section
);
8821 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
8826 /* Write the header. */
8827 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
8828 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
8829 bfd_putl32 (sub_dst
->size
, dmth
->size
);
8832 off
+= sizeof (struct vms_dmt_header
);
8835 /* For each section (ie for each psect). */
8836 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8838 /* Only consider interesting sections. */
8839 if (!(o
->flags
& SEC_ALLOC
))
8841 if (o
->flags
& SEC_LINKER_CREATED
)
8846 /* Write an entry. */
8847 struct vms_dmt_psect
*dmtp
;
8849 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
8850 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
8852 bfd_putl32 (o
->size
, dmtp
->length
);
8855 off
+= sizeof (struct vms_dmt_psect
);
8858 bfd_putl32 (psect_count
, dmth
->psect_count
);
8863 contents
= bfd_zalloc (info
->output_bfd
, off
);
8864 if (contents
== NULL
)
8866 dmt
->contents
= contents
;
8871 BFD_ASSERT (off
== dmt
->size
);
8879 /* Read the contents of a section.
8880 buf points to a buffer of buf_size bytes to be filled with
8881 section data (starting at offset into section) */
8884 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
8885 void *buf
, file_ptr offset
,
8886 bfd_size_type count
)
8890 /* Image are easy. */
8891 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8892 return _bfd_generic_get_section_contents (abfd
, section
,
8893 buf
, offset
, count
);
8896 if (offset
+ count
< count
8897 || offset
+ count
> section
->size
)
8899 bfd_set_error (bfd_error_invalid_operation
);
8903 /* Alloc in memory and read ETIRs. */
8904 BFD_ASSERT (section
->contents
== NULL
);
8906 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8908 BFD_ASSERT (sec
->contents
== NULL
);
8910 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
8912 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
8913 if (sec
->contents
== NULL
)
8917 if (!alpha_vms_read_sections_content (abfd
, NULL
))
8919 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8920 if (section
->contents
)
8921 section
->flags
|= SEC_IN_MEMORY
;
8922 memcpy (buf
, section
->contents
+ offset
, count
);
8927 /* Set the format of a file being written. */
8930 alpha_vms_mkobject (bfd
* abfd
)
8932 const bfd_arch_info_type
*arch
;
8934 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
8936 if (!vms_initialize (abfd
))
8939 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
8940 if (PRIV (recwr
.buf
) == NULL
)
8943 arch
= bfd_scan_arch ("alpha");
8947 bfd_set_error (bfd_error_wrong_format
);
8951 abfd
->arch_info
= arch
;
8958 /* Called when the BFD is being closed to do any necessary cleanup. */
8961 vms_close_and_cleanup (bfd
* abfd
)
8963 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
8965 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
8968 if (abfd
->format
== bfd_archive
)
8970 bfd_release (abfd
, abfd
->tdata
.any
);
8971 abfd
->tdata
.any
= NULL
;
8975 if (PRIV (recrd
.buf
) != NULL
)
8976 free (PRIV (recrd
.buf
));
8978 if (PRIV (sections
) != NULL
)
8979 free (PRIV (sections
));
8981 bfd_release (abfd
, abfd
->tdata
.any
);
8982 abfd
->tdata
.any
= NULL
;
8985 if (abfd
->direction
== write_direction
)
8987 /* Last step on VMS is to convert the file to variable record length
8989 if (bfd_cache_close (abfd
) != TRUE
)
8991 if (_bfd_vms_convert_to_var_unix_filename (abfd
->filename
) != TRUE
)
8999 /* Called when a new section is created. */
9002 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9006 vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n",
9007 abfd
, section
->index
, section
->name
));
9009 bfd_set_section_alignment (abfd
, section
, 0);
9011 vms_debug2 ((7, "%d: %s\n", section
->index
, section
->name
));
9013 amt
= sizeof (struct vms_section_data_struct
);
9014 section
->used_by_bfd
= (PTR
) bfd_zalloc (abfd
, amt
);
9015 if (section
->used_by_bfd
== NULL
)
9018 /* Create the section symbol. */
9019 return _bfd_generic_new_section_hook (abfd
, section
);
9022 /* Part 4.5, symbols. */
9024 /* Print symbol to file according to how. how is one of
9025 bfd_print_symbol_name just print the name
9026 bfd_print_symbol_more print more (???)
9027 bfd_print_symbol_all print all we know, which is not much right now :-). */
9030 vms_print_symbol (bfd
* abfd
,
9033 bfd_print_symbol_type how
)
9035 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9036 abfd
, file
, symbol
, how
));
9040 case bfd_print_symbol_name
:
9041 case bfd_print_symbol_more
:
9042 fprintf ((FILE *)file
," %s", symbol
->name
);
9045 case bfd_print_symbol_all
:
9047 const char *section_name
= symbol
->section
->name
;
9049 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9051 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9057 /* Return information about symbol in ret.
9059 fill type, value and name
9062 B bss segment symbol
9064 D data segment symbol
9066 t a static function symbol
9067 T text segment symbol
9072 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9078 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9080 sec
= symbol
->section
;
9087 else if (bfd_is_com_section (sec
))
9089 else if (bfd_is_abs_section (sec
))
9091 else if (bfd_is_und_section (sec
))
9093 else if (bfd_is_ind_section (sec
))
9095 else if ((symbol
->flags
& BSF_FUNCTION
)
9096 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9098 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9100 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9105 if (ret
->type
!= 'U')
9106 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9109 ret
->name
= symbol
->name
;
9112 /* Return TRUE if the given symbol sym in the BFD abfd is
9113 a compiler generated local label, else return FALSE. */
9116 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9119 vms_debug2 ((1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd
, name
));
9120 return name
[0] == '$';
9123 /* Part 4.7, writing an object file. */
9125 /* Sets the contents of the section section in BFD abfd to the data starting
9126 in memory at LOCATION. The data is written to the output section starting
9127 at offset offset for count bytes.
9129 Normally TRUE is returned, else FALSE. Possible error returns are:
9130 o bfd_error_no_contents - The output section does not have the
9131 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9132 o and some more too */
9135 _bfd_vms_set_section_contents (bfd
* abfd
,
9137 const void * location
,
9139 bfd_size_type count
)
9141 if (section
->contents
== NULL
)
9143 section
->contents
= bfd_alloc (abfd
, section
->size
);
9144 if (section
->contents
== NULL
)
9147 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9153 /* Set the architecture and machine type in BFD abfd to arch and mach.
9154 Find the correct pointer to a structure and insert it into the arch_info
9158 alpha_vms_set_arch_mach (bfd
*abfd
,
9159 enum bfd_architecture arch
, unsigned long mach
)
9161 if (arch
!= bfd_arch_alpha
9162 && arch
!= bfd_arch_unknown
)
9165 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9168 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9171 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9172 asection
*sec
, flagword no_flags
, flagword flags
)
9174 vms_section_data (sec
)->no_flags
= no_flags
;
9175 vms_section_data (sec
)->flags
= flags
;
9178 struct vms_private_data_struct
*
9179 bfd_vms_get_data (bfd
*abfd
)
9181 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9184 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9185 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9186 #define vms_bfd_copy_link_hash_symbol_type \
9187 _bfd_generic_copy_link_hash_symbol_type
9188 #define vms_bfd_is_group_section bfd_generic_is_group_section
9189 #define vms_bfd_discard_group bfd_generic_discard_group
9190 #define vms_section_already_linked _bfd_generic_section_already_linked
9191 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9192 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9194 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9195 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9196 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9197 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9198 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9199 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9201 /* Symbols table. */
9202 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9203 #define alpha_vms_bfd_is_target_special_symbol \
9204 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9205 #define alpha_vms_print_symbol vms_print_symbol
9206 #define alpha_vms_get_symbol_info vms_get_symbol_info
9207 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9208 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9209 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9210 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9211 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9212 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_dst_line
9213 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9215 /* Generic table. */
9216 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9217 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9218 #define alpha_vms_new_section_hook vms_new_section_hook
9219 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9220 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9222 #define alpha_vms_bfd_get_relocated_section_contents \
9223 bfd_generic_get_relocated_section_contents
9225 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9226 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9227 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9228 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9229 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9230 #define alpha_vms_section_already_linked \
9231 _bfd_generic_section_already_linked
9233 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9234 #define alpha_vms_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
9235 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9236 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9237 _bfd_generic_copy_link_hash_symbol_type
9239 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9241 #define alpha_vms_get_dynamic_symtab_upper_bound \
9242 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9243 #define alpha_vms_canonicalize_dynamic_symtab \
9244 _bfd_nodynamic_canonicalize_dynamic_symtab
9245 #define alpha_vms_get_dynamic_reloc_upper_bound \
9246 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9247 #define alpha_vms_canonicalize_dynamic_reloc \
9248 _bfd_nodynamic_canonicalize_dynamic_reloc
9250 const bfd_target vms_alpha_vec
=
9252 "vms-alpha", /* Name. */
9253 bfd_target_evax_flavour
,
9254 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9255 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9257 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9258 | WP_TEXT
| D_PAGED
), /* Object flags. */
9259 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9260 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9261 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9262 0, /* symbol_leading_char. */
9263 ' ', /* ar_pad_char. */
9264 15, /* ar_max_namelen. */
9265 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9266 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9267 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9268 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9269 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9270 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9272 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9273 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9274 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9275 _bfd_vms_lib_alpha_mkarchive
, bfd_false
},
9276 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9277 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9279 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9280 BFD_JUMP_TABLE_COPY (vms
),
9281 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9282 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9283 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9284 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9285 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9286 BFD_JUMP_TABLE_LINK (alpha_vms
),
9287 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),