1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright (C) 1996-2014 Free Software Foundation, Inc.
4 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
5 Major rewrite by Adacore.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
25 o Generation of shared image
26 o Relocation optimizations
32 o protected sections (for messages)
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
54 #include "vms/esgps.h"
63 #include "vms/esdfm.h"
64 #include "vms/esdfv.h"
70 #include "vms/internal.h"
73 #define MIN(a,b) ((a) < (b) ? (a) : (b))
75 /* The r_type field in a reloc is one of the following values. */
76 #define ALPHA_R_IGNORE 0
77 #define ALPHA_R_REFQUAD 1
78 #define ALPHA_R_BRADDR 2
79 #define ALPHA_R_HINT 3
80 #define ALPHA_R_SREL16 4
81 #define ALPHA_R_SREL32 5
82 #define ALPHA_R_SREL64 6
83 #define ALPHA_R_OP_PUSH 7
84 #define ALPHA_R_OP_STORE 8
85 #define ALPHA_R_OP_PSUB 9
86 #define ALPHA_R_OP_PRSHIFT 10
87 #define ALPHA_R_LINKAGE 11
88 #define ALPHA_R_REFLONG 12
89 #define ALPHA_R_CODEADDR 13
90 #define ALPHA_R_NOP 14
91 #define ALPHA_R_BSR 15
92 #define ALPHA_R_LDA 16
93 #define ALPHA_R_BOH 17
95 /* These are used with DST_S_C_LINE_NUM. */
96 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
98 /* These are used with DST_S_C_SOURCE */
100 #define DST_S_B_PCLINE_UNSBYTE 1
101 #define DST_S_W_PCLINE_UNSWORD 1
102 #define DST_S_L_PCLINE_UNSLONG 1
104 #define DST_S_B_MODBEG_NAME 14
105 #define DST_S_L_RTNBEG_ADDRESS 5
106 #define DST_S_B_RTNBEG_NAME 13
107 #define DST_S_L_RTNEND_SIZE 5
109 /* These are used with DST_S_C_SOURCE. */
110 #define DST_S_C_SOURCE_HEADER_SIZE 4
112 #define DST_S_B_SRC_DF_LENGTH 1
113 #define DST_S_W_SRC_DF_FILEID 3
114 #define DST_S_B_SRC_DF_FILENAME 20
115 #define DST_S_B_SRC_UNSBYTE 1
116 #define DST_S_W_SRC_UNSWORD 1
117 #define DST_S_L_SRC_UNSLONG 1
119 /* Debugger symbol definitions. */
121 #define DBG_S_L_DMT_MODBEG 0
122 #define DBG_S_L_DST_SIZE 4
123 #define DBG_S_W_DMT_PSECT_COUNT 8
124 #define DBG_S_C_DMT_HEADER_SIZE 12
126 #define DBG_S_L_DMT_PSECT_START 0
127 #define DBG_S_L_DMT_PSECT_LENGTH 4
128 #define DBG_S_C_DMT_PSECT_SIZE 8
130 /* VMS module header. */
146 #define EMH_DATE_LENGTH 17
148 /* VMS End-Of-Module records (EOM/EEOM). */
152 unsigned int eom_l_total_lps
;
153 unsigned short eom_w_comcod
;
154 bfd_boolean eom_has_transfer
;
155 unsigned char eom_b_tfrflg
;
156 unsigned int eom_l_psindx
;
157 unsigned int eom_l_tfradr
;
160 struct vms_symbol_entry
166 unsigned char data_type
;
167 unsigned short flags
;
169 /* Section and offset/value of the symbol. */
173 /* Section and offset/value for the entry point (only for subprg). */
174 asection
*code_section
;
175 unsigned int code_value
;
177 /* Symbol vector offset. */
178 unsigned int symbol_vector
;
180 /* Length of the name. */
181 unsigned char namelen
;
186 /* Stack value for push/pop commands. */
194 #define STACKSIZE 128
196 /* A minimal decoding of DST compilation units. We only decode
197 what's needed to get to the line number information. */
207 struct srecinfo
*next
;
215 struct lineinfo
*next
;
222 struct funcinfo
*next
;
230 /* Chain the previously read compilation unit. */
233 /* The module name. */
236 /* The start offset and size of debug info in the DST section. */
240 /* The lowest and highest addresses contained in this compilation
241 unit as specified in the compilation unit header. */
245 /* The listing line table. */
246 struct lineinfo
*line_table
;
248 /* The source record table. */
249 struct srecinfo
*srec_table
;
251 /* A list of the functions found in this module. */
252 struct funcinfo
*func_table
;
254 /* Current allocation of file_table. */
255 unsigned int file_table_count
;
257 /* An array of the files making up this module. */
258 struct fileinfo
*file_table
;
261 /* BFD private data for alpha-vms. */
263 struct vms_private_data_struct
265 /* If true, relocs have been read. */
266 bfd_boolean reloc_done
;
268 /* Record input buffer. */
269 struct vms_rec_rd recrd
;
270 struct vms_rec_wr recwr
;
272 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
273 struct eom_struct eom_data
; /* data from EOM/EEOM record */
275 /* Transfer addresses (entry points). */
276 bfd_vma transfer_address
[4];
278 /* Array of GSD sections to get the correspond BFD one. */
279 unsigned int section_max
; /* Size of the sections array. */
280 unsigned int section_count
; /* Number of GSD sections. */
283 /* Array of raw symbols. */
284 struct vms_symbol_entry
**syms
;
286 /* Canonicalized symbols. */
289 /* Number of symbols. */
290 unsigned int gsd_sym_count
;
291 /* Size of the syms array. */
292 unsigned int max_sym_count
;
293 /* Number of procedure symbols. */
294 unsigned int norm_sym_count
;
296 /* Stack used to evaluate TIR/ETIR commands. */
297 struct stack_struct
*stack
;
300 /* Content reading. */
301 asection
*image_section
; /* section for image_ptr */
302 file_ptr image_offset
; /* Offset for image_ptr. */
304 struct module
*modules
; /* list of all compilation units */
306 /* The DST section. */
307 asection
*dst_section
;
309 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
310 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
312 /* Shared library support */
313 bfd_vma symvva
; /* relative virtual address of symbol vector */
315 unsigned char matchctl
;
317 /* Shared library index. This is used for input bfd while linking. */
318 unsigned int shr_index
;
320 /* Used to place structures in the file. */
323 /* Simply linked list of eisd. */
324 struct vms_internal_eisd_map
*eisd_head
;
325 struct vms_internal_eisd_map
*eisd_tail
;
327 /* Simply linked list of eisd for shared libraries. */
328 struct vms_internal_eisd_map
*gbl_eisd_head
;
329 struct vms_internal_eisd_map
*gbl_eisd_tail
;
331 /* linkage index counter used by conditional store commands */
332 unsigned int vms_linkage_index
;
335 #define PRIV2(abfd, name) \
336 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
337 #define PRIV(name) PRIV2(abfd,name)
340 /* Used to keep extra VMS specific information for a given section.
342 reloc_size holds the size of the relocation stream, note this
343 is very different from the number of relocations as VMS relocations
346 reloc_stream is the actual stream of relocation entries. */
348 struct vms_section_data_struct
350 /* Maximnum number of entries in sec->relocation. */
353 /* Corresponding eisd. Used only while generating executables. */
354 struct vms_internal_eisd_map
*eisd
;
356 /* PSC flags to be clear. */
359 /* PSC flags to be set. */
363 #define vms_section_data(sec) \
364 ((struct vms_section_data_struct *)sec->used_by_bfd)
366 /* To be called from the debugger. */
367 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*abfd
);
369 static int vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
);
370 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
371 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
372 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
373 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
375 static void alpha_vms_add_fixup_lr (struct bfd_link_info
*, unsigned int,
377 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*info
);
378 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*info
);
387 /* Number of elements in VEC. */
389 #define VEC_COUNT(VEC) ((VEC).nbr_el)
391 /* Get the address of the Nth element. */
393 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
395 #define VEC_INIT(VEC) \
402 /* Be sure there is room for a new element. */
404 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
406 /* Allocate room for a new element and return its address. */
408 #define VEC_APPEND(VEC, TYPE) \
409 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
411 /* Append an element. */
413 #define VEC_APPEND_EL(VEC, TYPE, EL) \
414 (*(VEC_APPEND (VEC, TYPE)) = EL)
416 struct alpha_vms_vma_ref
418 bfd_vma vma
; /* Vma in the output. */
419 bfd_vma ref
; /* Reference in the input. */
422 struct alpha_vms_shlib_el
425 bfd_boolean has_fixups
;
427 struct vector_type lp
; /* Vector of bfd_vma. */
428 struct vector_type ca
; /* Vector of bfd_vma. */
429 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
432 /* Alpha VMS linker hash table. */
434 struct alpha_vms_link_hash_table
436 struct bfd_link_hash_table root
;
438 /* Vector of shared libraries. */
439 struct vector_type shrlibs
;
444 /* Base address. Used by fixups. */
448 #define alpha_vms_link_hash(INFO) \
449 ((struct alpha_vms_link_hash_table *)(INFO->hash))
451 /* Alpha VMS linker hash table entry. */
453 struct alpha_vms_link_hash_entry
455 struct bfd_link_hash_entry root
;
457 /* Pointer to the original vms symbol. */
458 struct vms_symbol_entry
*sym
;
463 /* Read & process EIHD record.
464 Return TRUE on success, FALSE on error. */
467 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
468 unsigned int *eihs_offset
)
470 unsigned int imgtype
, size
;
472 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
474 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
476 size
= bfd_getl32 (eihd
->size
);
477 imgtype
= bfd_getl32 (eihd
->imgtype
);
479 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
480 abfd
->flags
|= EXEC_P
;
482 symvva
= bfd_getl64 (eihd
->symvva
);
485 PRIV (symvva
) = symvva
;
486 abfd
->flags
|= DYNAMIC
;
489 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
490 PRIV (matchctl
) = eihd
->matchctl
;
492 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
493 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
495 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
496 size
, imgtype
, (unsigned long)symvva
,
497 *eisd_offset
, *eihs_offset
));
502 /* Read & process EISD record.
503 Return TRUE on success, FALSE on error. */
506 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
508 int section_count
= 0;
510 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
514 struct vms_eisd
*eisd
;
515 unsigned int rec_size
;
517 unsigned long long vaddr
;
524 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
525 rec_size
= bfd_getl32 (eisd
->eisdsize
);
530 /* Skip to next block if pad. */
531 if (rec_size
== 0xffffffff)
533 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
539 size
= bfd_getl32 (eisd
->secsize
);
540 vaddr
= bfd_getl64 (eisd
->virt_addr
);
541 flags
= bfd_getl32 (eisd
->flags
);
542 vbn
= bfd_getl32 (eisd
->vbn
);
544 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
545 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
547 /* VMS combines psects from .obj files into isects in the .exe. This
548 process doesn't preserve enough information to reliably determine
549 what's in each section without examining the data. This is
550 especially true of DWARF debug sections. */
551 bfd_flags
= SEC_ALLOC
;
553 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
555 if (flags
& EISD__M_EXE
)
556 bfd_flags
|= SEC_CODE
;
558 if (flags
& EISD__M_NONSHRADR
)
559 bfd_flags
|= SEC_DATA
;
561 if (!(flags
& EISD__M_WRT
))
562 bfd_flags
|= SEC_READONLY
;
564 if (flags
& EISD__M_DZRO
)
565 bfd_flags
|= SEC_DATA
;
567 if (flags
& EISD__M_FIXUPVEC
)
568 bfd_flags
|= SEC_DATA
;
570 if (flags
& EISD__M_CRF
)
571 bfd_flags
|= SEC_DATA
;
573 if (flags
& EISD__M_GBL
)
575 name
= _bfd_vms_save_counted_string (eisd
->gblnam
);
576 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
577 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
579 else if (flags
& EISD__M_FIXUPVEC
)
581 else if (eisd
->type
== EISD__K_USRSTACK
)
587 name
= (char*) bfd_alloc (abfd
, 32);
588 if (flags
& EISD__M_DZRO
)
590 else if (flags
& EISD__M_EXE
)
592 else if (!(flags
& EISD__M_WRT
))
596 BFD_ASSERT (section_count
< 999);
597 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
600 section
= bfd_make_section (abfd
, name
);
605 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
606 section
->size
= size
;
607 section
->vma
= vaddr
;
609 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
616 /* Read & process EIHS record.
617 Return TRUE on success, FALSE on error. */
620 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
622 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
623 unsigned int gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
624 unsigned int gstsize ATTRIBUTE_UNUSED
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
625 unsigned int dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
626 unsigned int dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
627 unsigned int dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
628 unsigned int dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
632 vms_debug (8, "_bfd_vms_slurp_ihs\n");
633 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
634 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
639 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
641 section
= bfd_make_section (abfd
, "$DST$");
645 section
->size
= dstsize
;
646 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
648 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
651 PRIV (dst_section
) = section
;
652 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
657 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
659 section
= bfd_make_section (abfd
, "$DMT$");
663 section
->size
= dmtbytes
;
664 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
666 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
672 if (bfd_seek (abfd
, VMS_BLOCK_SIZE
* (gstvbn
- 1), SEEK_SET
))
674 bfd_set_error (bfd_error_file_truncated
);
678 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
681 abfd
->flags
|= HAS_SYMS
;
687 /* Object file reading. */
689 /* Object file input functions. */
691 /* Get next record from object file to vms_buf.
692 Set PRIV(buf_size) and return it
694 This is a little tricky since it should be portable.
696 The openVMS object file has 'variable length' which means that
697 read() returns data in chunks of (hopefully) correct and expected
698 size. The linker (and other tools on VMS) depend on that. Unix
699 doesn't know about 'formatted' files, so reading and writing such
700 an object file in a Unix environment is not trivial.
702 With the tool 'file' (available on all VMS FTP sites), one
703 can view and change the attributes of a file. Changing from
704 'variable length' to 'fixed length, 512 bytes' reveals the
705 record size at the first 2 bytes of every record. The same
706 may happen during the transfer of object files from VMS to Unix,
707 at least with UCX, the DEC implementation of TCP/IP.
709 The VMS format repeats the size at bytes 2 & 3 of every record.
711 On the first call (file_format == FF_UNKNOWN) we check if
712 the first and the third byte pair (!) of the record match.
713 If they do it's an object file in an Unix environment or with
714 wrong attributes (FF_FOREIGN), else we should be in a VMS
715 environment where read() returns the record size (FF_NATIVE).
717 Reading is always done in 2 steps:
718 1. first just the record header is read and the size extracted,
719 2. then the read buffer is adjusted and the remaining bytes are
722 All file I/O is done on even file positions. */
724 #define VMS_OBJECT_ADJUSTMENT 2
727 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
729 /* Set the file format once for all on the first invocation. */
730 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
732 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
733 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
734 PRIV (recrd
.file_format
) = FF_FOREIGN
;
736 PRIV (recrd
.file_format
) = FF_NATIVE
;
739 /* The adjustment is needed only in an Unix environment. */
740 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
741 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
744 /* Implement step #1 of the object record reading procedure.
745 Return the record type or -1 on failure. */
748 _bfd_vms_get_object_record (bfd
*abfd
)
750 unsigned int test_len
= 6;
753 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
755 /* Skip alignment byte if the current position is odd. */
756 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
758 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
760 bfd_set_error (bfd_error_file_truncated
);
765 /* Read the record header */
766 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
768 bfd_set_error (bfd_error_file_truncated
);
772 /* Reset the record pointer. */
773 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
774 maybe_adjust_record_pointer_for_object (abfd
);
776 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
779 type
= bfd_getl16 (PRIV (recrd
.rec
));
781 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
782 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
787 /* Implement step #2 of the object record reading procedure.
788 Return the size of the record or 0 on failure. */
791 vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
)
793 unsigned int to_read
;
795 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
797 /* Extract record size. */
798 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
800 if (PRIV (recrd
.rec_size
) == 0)
802 bfd_set_error (bfd_error_file_truncated
);
806 /* That's what the linker manual says. */
807 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
809 bfd_set_error (bfd_error_file_truncated
);
813 /* Take into account object adjustment. */
814 to_read
= PRIV (recrd
.rec_size
);
815 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
816 to_read
+= VMS_OBJECT_ADJUSTMENT
;
818 /* Adjust the buffer. */
819 if (to_read
> PRIV (recrd
.buf_size
))
822 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
823 if (PRIV (recrd
.buf
) == NULL
)
825 PRIV (recrd
.buf_size
) = to_read
;
828 /* Read the remaining record. */
829 to_read
-= read_so_far
;
831 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
833 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
835 bfd_set_error (bfd_error_file_truncated
);
839 /* Reset the record pointer. */
840 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
841 maybe_adjust_record_pointer_for_object (abfd
);
843 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
844 PRIV (recrd
.rec_size
)));
846 return PRIV (recrd
.rec_size
);
849 /* Read and process emh record.
850 Return TRUE on success, FALSE on error. */
853 _bfd_vms_slurp_ehdr (bfd
*abfd
)
856 unsigned char *vms_rec
;
859 vms_rec
= PRIV (recrd
.rec
);
861 vms_debug2 ((2, "HDR/EMH\n"));
863 subtype
= bfd_getl16 (vms_rec
+ 4);
865 vms_debug2 ((3, "subtype %d\n", subtype
));
871 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
872 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
873 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
874 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
875 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20);
876 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
877 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
);
879 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
883 PRIV (hdr_data
).hdr_c_lnm
=
884 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
888 PRIV (hdr_data
).hdr_c_src
=
889 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
893 PRIV (hdr_data
).hdr_c_ttl
=
894 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
903 bfd_set_error (bfd_error_wrong_format
);
910 /* Typical sections for evax object files. */
912 #define EVAX_ABS_NAME "$ABS$"
913 #define EVAX_CODE_NAME "$CODE$"
914 #define EVAX_LINK_NAME "$LINK$"
915 #define EVAX_DATA_NAME "$DATA$"
916 #define EVAX_BSS_NAME "$BSS$"
917 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
918 #define EVAX_READONLY_NAME "$READONLY$"
919 #define EVAX_LITERAL_NAME "$LITERAL$"
920 #define EVAX_LITERALS_NAME "$LITERALS"
921 #define EVAX_COMMON_NAME "$COMMON$"
922 #define EVAX_LOCAL_NAME "$LOCAL$"
924 struct sec_flags_struct
926 const char *name
; /* Name of section. */
928 flagword flags_always
; /* Flags we set always. */
930 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
933 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
935 static const struct sec_flags_struct evax_section_flags
[] =
943 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
944 SEC_CODE
| SEC_READONLY
,
945 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
,
946 SEC_CODE
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
948 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
949 SEC_DATA
| SEC_READONLY
,
950 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
951 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
953 EGPS__V_REL
| EGPS__V_RD
,
954 SEC_DATA
| SEC_READONLY
,
955 EGPS__V_REL
| EGPS__V_RD
,
956 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
958 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
960 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
961 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
963 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
965 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
,
967 { EVAX_READONLYADDR_NAME
,
968 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
969 SEC_DATA
| SEC_READONLY
,
970 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
,
971 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
972 { EVAX_READONLY_NAME
,
973 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
,
974 SEC_DATA
| SEC_READONLY
,
975 EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
,
976 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
978 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
980 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
981 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
982 { EVAX_LITERALS_NAME
,
983 EGPS__V_PIC
| EGPS__V_OVR
,
984 SEC_DATA
| SEC_READONLY
,
985 EGPS__V_PIC
| EGPS__V_OVR
,
986 SEC_DATA
| SEC_READONLY
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
},
988 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
990 EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
,
991 SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
}
994 /* Retrieve BFD section flags by name and size. */
997 vms_secflag_by_name (const struct sec_flags_struct
*section_flags
,
1003 while (section_flags
[i
].name
!= NULL
)
1005 if (strcmp (name
, section_flags
[i
].name
) == 0)
1008 return section_flags
[i
].flags_hassize
;
1010 return section_flags
[i
].flags_always
;
1015 return section_flags
[i
].flags_hassize
;
1016 return section_flags
[i
].flags_always
;
1019 /* Retrieve VMS section flags by name and size. */
1022 vms_esecflag_by_name (const struct sec_flags_struct
*section_flags
,
1028 while (section_flags
[i
].name
!= NULL
)
1030 if (strcmp (name
, section_flags
[i
].name
) == 0)
1033 return section_flags
[i
].vflags_hassize
;
1035 return section_flags
[i
].vflags_always
;
1040 return section_flags
[i
].vflags_hassize
;
1041 return section_flags
[i
].vflags_always
;
1044 /* Add SYM to the symbol table of ABFD.
1045 Return FALSE in case of error. */
1048 add_symbol_entry (bfd
*abfd
, struct vms_symbol_entry
*sym
)
1050 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1052 if (PRIV (max_sym_count
) == 0)
1054 PRIV (max_sym_count
) = 128;
1055 PRIV (syms
) = bfd_malloc
1056 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1060 PRIV (max_sym_count
) *= 2;
1061 PRIV (syms
) = bfd_realloc
1063 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1065 if (PRIV (syms
) == NULL
)
1069 PRIV (syms
)[PRIV (gsd_sym_count
)++] = sym
;
1073 /* Create a symbol whose name is ASCIC and add it to ABFD.
1074 Return NULL in case of error. */
1076 static struct vms_symbol_entry
*
1077 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1079 struct vms_symbol_entry
*entry
;
1083 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1086 entry
->namelen
= len
;
1087 memcpy (entry
->name
, ascic
, len
);
1088 entry
->name
[len
] = 0;
1089 entry
->owner
= abfd
;
1091 if (!add_symbol_entry (abfd
, entry
))
1096 /* Read and process EGSD. Return FALSE on failure. */
1099 _bfd_vms_slurp_egsd (bfd
*abfd
)
1101 int gsd_type
, gsd_size
;
1102 unsigned char *vms_rec
;
1103 unsigned long base_addr
;
1105 vms_debug2 ((2, "EGSD\n"));
1107 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1108 PRIV (recrd
.rec_size
) -= 8;
1110 /* Calculate base address for each section. */
1113 while (PRIV (recrd
.rec_size
) > 0)
1115 vms_rec
= PRIV (recrd
.rec
);
1117 gsd_type
= bfd_getl16 (vms_rec
);
1118 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1120 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1125 /* Program section definition. */
1127 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1128 flagword new_flags
, vms_flags
;
1131 vms_flags
= bfd_getl16 (egps
->flags
);
1133 if ((vms_flags
& EGPS__V_REL
) == 0)
1135 /* Use the global absolute section for all
1136 absolute sections. */
1137 section
= bfd_abs_section_ptr
;
1142 unsigned long align_addr
;
1144 name
= _bfd_vms_save_counted_string (&egps
->namlng
);
1146 section
= bfd_make_section (abfd
, name
);
1150 section
->filepos
= 0;
1151 section
->size
= bfd_getl32 (egps
->alloc
);
1152 section
->alignment_power
= egps
->align
;
1154 vms_section_data (section
)->flags
= vms_flags
;
1155 vms_section_data (section
)->no_flags
= 0;
1157 new_flags
= vms_secflag_by_name (evax_section_flags
, name
,
1159 if (section
->size
> 0)
1160 new_flags
|= SEC_LOAD
;
1161 if (!(vms_flags
& EGPS__V_NOMOD
) && section
->size
> 0)
1163 /* Set RELOC and HAS_CONTENTS if the section is not
1164 demand-zero and not empty. */
1165 new_flags
|= SEC_HAS_CONTENTS
;
1166 if (vms_flags
& EGPS__V_REL
)
1167 new_flags
|= SEC_RELOC
;
1169 if (vms_flags
& EGPS__V_EXE
)
1171 /* Set CODE if section is executable. */
1172 new_flags
|= SEC_CODE
;
1173 new_flags
&= ~SEC_DATA
;
1175 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1178 /* Give a non-overlapping vma to non absolute sections. */
1179 align_addr
= (1 << section
->alignment_power
);
1180 if ((base_addr
% align_addr
) != 0)
1181 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1182 section
->vma
= (bfd_vma
)base_addr
;
1183 base_addr
+= section
->size
;
1186 /* Append it to the section array. */
1187 if (PRIV (section_count
) >= PRIV (section_max
))
1189 if (PRIV (section_max
) == 0)
1190 PRIV (section_max
) = 16;
1192 PRIV (section_max
) *= 2;
1193 PRIV (sections
) = bfd_realloc_or_free
1194 (PRIV (sections
), PRIV (section_max
) * sizeof (asection
*));
1195 if (PRIV (sections
) == NULL
)
1199 PRIV (sections
)[PRIV (section_count
)] = section
;
1200 PRIV (section_count
)++;
1207 struct vms_symbol_entry
*entry
;
1208 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1211 old_flags
= bfd_getl16 (egsy
->flags
);
1212 if (old_flags
& EGSY__V_DEF
)
1213 nameoff
= ESDF__B_NAMLNG
;
1215 nameoff
= ESRF__B_NAMLNG
;
1217 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1221 /* Allow only duplicate reference. */
1222 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1225 if (entry
->typ
== 0)
1227 entry
->typ
= gsd_type
;
1228 entry
->data_type
= egsy
->datyp
;
1229 entry
->flags
= old_flags
;
1232 if (old_flags
& EGSY__V_DEF
)
1234 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1236 entry
->value
= bfd_getl64 (esdf
->value
);
1237 entry
->section
= PRIV (sections
)[bfd_getl32 (esdf
->psindx
)];
1239 if (old_flags
& EGSY__V_NORM
)
1241 PRIV (norm_sym_count
)++;
1243 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1244 entry
->code_section
=
1245 PRIV (sections
)[bfd_getl32 (esdf
->ca_psindx
)];
1253 struct vms_symbol_entry
*entry
;
1254 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1257 old_flags
= bfd_getl16 (egst
->header
.flags
);
1259 entry
= add_symbol (abfd
, &egst
->namlng
);
1264 entry
->typ
= gsd_type
;
1265 entry
->data_type
= egst
->header
.datyp
;
1266 entry
->flags
= old_flags
;
1268 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1270 if (old_flags
& EGSY__V_REL
)
1271 entry
->section
= PRIV (sections
)[bfd_getl32 (egst
->psindx
)];
1273 entry
->section
= bfd_abs_section_ptr
;
1275 entry
->value
= bfd_getl64 (egst
->lp_2
);
1277 if (old_flags
& EGSY__V_NORM
)
1279 PRIV (norm_sym_count
)++;
1281 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1282 entry
->code_section
= bfd_abs_section_ptr
;
1289 /* Currently ignored. */
1294 (*_bfd_error_handler
) (_("Unknown EGSD subtype %d"), gsd_type
);
1295 bfd_set_error (bfd_error_bad_value
);
1299 PRIV (recrd
.rec_size
) -= gsd_size
;
1300 PRIV (recrd
.rec
) += gsd_size
;
1303 if (PRIV (gsd_sym_count
) > 0)
1304 abfd
->flags
|= HAS_SYMS
;
1309 /* Stack routines for vms ETIR commands. */
1311 /* Push value and section index. */
1314 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1316 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1317 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1319 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1320 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1322 if (PRIV (stackptr
) >= STACKSIZE
)
1324 bfd_set_error (bfd_error_bad_value
);
1325 (*_bfd_error_handler
) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1330 /* Pop value and section index. */
1333 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1335 if (PRIV (stackptr
) == 0)
1337 bfd_set_error (bfd_error_bad_value
);
1338 (*_bfd_error_handler
) (_("Stack underflow in _bfd_vms_pop"));
1342 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1343 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1345 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1348 /* Routines to fill sections contents during tir/etir read. */
1350 /* Initialize image buffer pointer to be filled. */
1353 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1357 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1359 sec
= PRIV (sections
)[sect
];
1363 /* Reading contents to an output bfd. */
1365 if (sec
->output_section
== NULL
)
1367 /* Section discarded. */
1368 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1370 /* This is not used. */
1371 PRIV (image_section
) = NULL
;
1372 PRIV (image_offset
) = 0;
1375 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1376 PRIV (image_section
) = sec
->output_section
;
1380 PRIV (image_offset
) = vma
;
1381 PRIV (image_section
) = sec
;
1385 /* Increment image buffer pointer by offset. */
1388 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1390 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1392 PRIV (image_offset
) += offset
;
1395 /* Save current DST location counter under specified index. */
1398 dst_define_location (bfd
*abfd
, unsigned int loc
)
1400 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1402 /* Grow the ptr offset table if necessary. */
1403 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1405 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1406 (loc
+ 1) * sizeof (unsigned int));
1407 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1410 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1413 /* Restore saved DST location counter from specified index. */
1416 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1418 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1420 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1423 /* Retrieve saved DST location counter from specified index. */
1426 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1428 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1430 return PRIV (dst_ptr_offsets
)[loc
];
1433 /* Write multiple bytes to section image. */
1436 image_write (bfd
*abfd
, unsigned char *ptr
, int size
)
1439 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1440 (long)PRIV (image_offset
));
1441 _bfd_hexdump (9, ptr
, size
, 0);
1444 if (PRIV (image_section
)->contents
!= NULL
)
1446 asection
*sec
= PRIV (image_section
);
1447 file_ptr off
= PRIV (image_offset
);
1450 if (off
> (file_ptr
)sec
->size
1451 || size
> (file_ptr
)sec
->size
1452 || off
+ size
> (file_ptr
)sec
->size
)
1454 bfd_set_error (bfd_error_bad_value
);
1458 memcpy (sec
->contents
+ off
, ptr
, size
);
1461 PRIV (image_offset
) += size
;
1465 /* Write byte to section image. */
1468 image_write_b (bfd
* abfd
, unsigned int value
)
1470 unsigned char data
[1];
1472 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1476 return image_write (abfd
, data
, sizeof (data
));
1479 /* Write 2-byte word to image. */
1482 image_write_w (bfd
* abfd
, unsigned int value
)
1484 unsigned char data
[2];
1486 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1488 bfd_putl16 (value
, data
);
1489 return image_write (abfd
, data
, sizeof (data
));
1492 /* Write 4-byte long to image. */
1495 image_write_l (bfd
* abfd
, unsigned long value
)
1497 unsigned char data
[4];
1499 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1501 bfd_putl32 (value
, data
);
1502 return image_write (abfd
, data
, sizeof (data
));
1505 /* Write 8-byte quad to image. */
1508 image_write_q (bfd
* abfd
, bfd_vma value
)
1510 unsigned char data
[8];
1512 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1514 bfd_putl64 (value
, data
);
1515 return image_write (abfd
, data
, sizeof (data
));
1519 _bfd_vms_etir_name (int cmd
)
1523 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1524 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1525 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1526 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1527 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1528 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1529 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1530 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1531 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1532 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1533 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1534 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1535 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1536 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1537 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1538 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1539 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1540 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1541 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1542 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1543 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1544 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1545 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1546 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1547 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1548 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1549 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1550 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1551 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1552 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1553 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1554 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1555 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1556 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1557 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1558 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1559 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1560 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1561 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1562 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1563 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1564 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1565 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1566 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1567 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1568 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1569 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1570 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1571 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1574 /* These names have not yet been added to this switch statement. */
1575 (*_bfd_error_handler
) (_("unknown ETIR command %d"), cmd
);
1580 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1583 _bfd_vms_get_value (bfd
*abfd
, const unsigned char *ascic
,
1584 struct bfd_link_info
*info
,
1586 struct alpha_vms_link_hash_entry
**hp
)
1591 struct alpha_vms_link_hash_entry
*h
;
1593 /* Not linking. Do not try to resolve the symbol. */
1602 for (i
= 0; i
< len
; i
++)
1603 name
[i
] = ascic
[i
+ 1];
1606 h
= (struct alpha_vms_link_hash_entry
*)
1607 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1612 && (h
->root
.type
== bfd_link_hash_defined
1613 || h
->root
.type
== bfd_link_hash_defweak
))
1614 *vma
= h
->root
.u
.def
.value
1615 + h
->root
.u
.def
.section
->output_offset
1616 + h
->root
.u
.def
.section
->output_section
->vma
;
1617 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1621 if (!(*info
->callbacks
->undefined_symbol
)
1622 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
))
1630 #define RELC_SHR_BASE 0x10000
1631 #define RELC_SEC_BASE 0x20000
1632 #define RELC_MASK 0x0ffff
1635 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1637 /* Handle undefined symbols. */
1638 if (h
== NULL
|| h
->sym
== NULL
)
1641 if (h
->sym
->typ
== EGSD__C_SYMG
)
1643 if (h
->sym
->flags
& EGSY__V_REL
)
1644 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1647 /* Can this happen (non-relocatable symg) ? I'd like to see
1652 if (h
->sym
->typ
== EGSD__C_SYM
)
1654 if (h
->sym
->flags
& EGSY__V_REL
)
1663 alpha_vms_get_sym_value (asection
*sect
, bfd_vma addr
)
1665 return sect
->output_section
->vma
+ sect
->output_offset
+ addr
;
1669 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1670 unsigned int rel
, bfd_vma vma
)
1672 asection
*sec
= PRIV (sections
)[rel
& RELC_MASK
];
1676 if (sec
->output_section
== NULL
)
1678 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1681 return vma
+ sec
->vma
;
1684 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1685 the output section (used during linking).
1686 Return FALSE in case of error. */
1689 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1692 unsigned int length
;
1693 unsigned char *maxptr
;
1698 struct alpha_vms_link_hash_entry
*h
;
1700 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1701 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1703 ptr
= PRIV (recrd
.rec
);
1704 length
= PRIV (recrd
.rec_size
);
1705 maxptr
= ptr
+ length
;
1707 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1709 while (ptr
< maxptr
)
1711 int cmd
= bfd_getl16 (ptr
);
1712 int cmd_length
= bfd_getl16 (ptr
+ 2);
1717 _bfd_vms_debug (4, "etir: %s(%d)\n",
1718 _bfd_vms_etir_name (cmd
), cmd
);
1719 _bfd_hexdump (8, ptr
, cmd_length
- 4, 0);
1727 stack 32 bit value of symbol (high bits set to 0). */
1728 case ETIR__C_STA_GBL
:
1729 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1730 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1736 stack 32 bit value, sign extend to 64 bit. */
1737 case ETIR__C_STA_LW
:
1738 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1744 stack 64 bit value of symbol. */
1745 case ETIR__C_STA_QW
:
1746 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1749 /* Stack psect base plus quadword offset
1750 arg: lw section index
1751 qw signed quadword offset (low 32 bits)
1753 Stack qw argument and section index
1754 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1755 case ETIR__C_STA_PQ
:
1759 psect
= bfd_getl32 (ptr
);
1760 if ((unsigned int) psect
>= PRIV (section_count
))
1762 (*_bfd_error_handler
) (_("bad section index in %s"),
1763 _bfd_vms_etir_name (cmd
));
1764 bfd_set_error (bfd_error_bad_value
);
1767 op1
= bfd_getl64 (ptr
+ 4);
1768 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1772 case ETIR__C_STA_LI
:
1773 case ETIR__C_STA_MOD
:
1774 case ETIR__C_STA_CKARG
:
1775 (*_bfd_error_handler
) (_("unsupported STA cmd %s"),
1776 _bfd_vms_etir_name (cmd
));
1780 /* Store byte: pop stack, write byte
1783 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1784 if (rel1
!= RELC_NONE
)
1786 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1789 /* Store word: pop stack, write word
1792 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1793 if (rel1
!= RELC_NONE
)
1795 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1798 /* Store longword: pop stack, write longword
1800 case ETIR__C_STO_LW
:
1801 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1802 if (rel1
& RELC_SEC_BASE
)
1804 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1807 else if (rel1
& RELC_SHR_BASE
)
1809 alpha_vms_add_fixup_lr (info
, rel1
& RELC_MASK
, op1
);
1812 if (rel1
!= RELC_NONE
)
1814 if (rel1
!= RELC_REL
)
1816 alpha_vms_add_lw_reloc (info
);
1818 image_write_l (abfd
, op1
);
1821 /* Store quadword: pop stack, write quadword
1823 case ETIR__C_STO_QW
:
1824 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1825 if (rel1
& RELC_SEC_BASE
)
1827 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1830 else if (rel1
& RELC_SHR_BASE
)
1832 if (rel1
!= RELC_NONE
)
1834 if (rel1
!= RELC_REL
)
1836 alpha_vms_add_qw_reloc (info
);
1838 image_write_q (abfd
, op1
);
1841 /* Store immediate repeated: pop stack for repeat count
1844 case ETIR__C_STO_IMMR
:
1848 size
= bfd_getl32 (ptr
);
1849 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1850 if (rel1
!= RELC_NONE
)
1853 image_write (abfd
, ptr
+ 4, size
);
1857 /* Store global: write symbol value
1858 arg: cs global symbol name. */
1859 case ETIR__C_STO_GBL
:
1860 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1863 if (h
->sym
->typ
== EGSD__C_SYMG
)
1865 alpha_vms_add_fixup_qr
1866 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
1871 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
1873 alpha_vms_add_qw_reloc (info
);
1876 image_write_q (abfd
, op1
);
1879 /* Store code address: write address of entry point
1880 arg: cs global symbol name (procedure). */
1881 case ETIR__C_STO_CA
:
1882 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1885 if (h
->sym
->flags
& EGSY__V_NORM
)
1887 /* That's really a procedure. */
1888 if (h
->sym
->typ
== EGSD__C_SYMG
)
1890 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
1891 op1
= h
->sym
->symbol_vector
;
1895 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1896 h
->sym
->code_value
);
1897 alpha_vms_add_qw_reloc (info
);
1902 /* Symbol is not a procedure. */
1906 image_write_q (abfd
, op1
);
1909 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1911 case ETIR__C_STO_OFF
:
1912 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1914 if (!(rel1
& RELC_SEC_BASE
))
1917 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1919 image_write_q (abfd
, op1
);
1923 arg: lw count of bytes
1925 case ETIR__C_STO_IMM
:
1929 size
= bfd_getl32 (ptr
);
1930 image_write (abfd
, ptr
+ 4, size
);
1934 /* This code is 'reserved to digital' according to the openVMS
1935 linker manual, however it is generated by the DEC C compiler
1936 and defined in the include file.
1937 FIXME, since the following is just a guess
1938 store global longword: store 32bit value of symbol
1939 arg: cs symbol name. */
1940 case ETIR__C_STO_GBL_LW
:
1941 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1945 image_write_l (abfd
, op1
);
1948 case ETIR__C_STO_RB
:
1949 case ETIR__C_STO_AB
:
1950 case ETIR__C_STO_LP_PSB
:
1951 (*_bfd_error_handler
) (_("%s: not supported"),
1952 _bfd_vms_etir_name (cmd
));
1955 case ETIR__C_STO_HINT_GBL
:
1956 case ETIR__C_STO_HINT_PS
:
1957 (*_bfd_error_handler
) (_("%s: not implemented"),
1958 _bfd_vms_etir_name (cmd
));
1962 /* 200 Store-conditional Linkage Pair
1964 case ETIR__C_STC_LP
:
1966 /* 202 Store-conditional Address at global address
1970 case ETIR__C_STC_GBL
:
1972 /* 203 Store-conditional Code Address at global address
1974 cs procedure name. */
1975 case ETIR__C_STC_GCA
:
1977 /* 204 Store-conditional Address at psect + offset
1981 case ETIR__C_STC_PS
:
1982 (*_bfd_error_handler
) (_("%s: not supported"),
1983 _bfd_vms_etir_name (cmd
));
1987 /* 201 Store-conditional Linkage Pair with Procedure Signature
1993 case ETIR__C_STC_LP_PSB
:
1994 _bfd_vms_get_value (abfd
, ptr
+ 4, info
, &op1
, &h
);
1997 if (h
->sym
->typ
== EGSD__C_SYMG
)
1999 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
2000 op1
= h
->sym
->symbol_vector
;
2005 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
2006 h
->sym
->code_value
);
2007 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2013 /* Undefined symbol. */
2017 image_write_q (abfd
, op1
);
2018 image_write_q (abfd
, op2
);
2021 /* 205 Store-conditional NOP at address of global
2023 case ETIR__C_STC_NOP_GBL
:
2026 /* 207 Store-conditional BSR at global address
2029 case ETIR__C_STC_BSR_GBL
:
2032 /* 209 Store-conditional LDA at global address
2035 case ETIR__C_STC_LDA_GBL
:
2038 /* 211 Store-conditional BSR or Hint at global address
2041 case ETIR__C_STC_BOH_GBL
:
2042 /* Currentl ignored. */
2045 /* 213 Store-conditional NOP,BSR or HINT at global address
2048 case ETIR__C_STC_NBH_GBL
:
2050 /* 206 Store-conditional NOP at pect + offset
2053 case ETIR__C_STC_NOP_PS
:
2055 /* 208 Store-conditional BSR at pect + offset
2058 case ETIR__C_STC_BSR_PS
:
2060 /* 210 Store-conditional LDA at psect + offset
2063 case ETIR__C_STC_LDA_PS
:
2065 /* 212 Store-conditional BSR or Hint at pect + offset
2068 case ETIR__C_STC_BOH_PS
:
2070 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2072 case ETIR__C_STC_NBH_PS
:
2073 (*_bfd_error_handler
) ("%s: not supported",
2074 _bfd_vms_etir_name (cmd
));
2078 /* Det relocation base: pop stack, set image location counter
2080 case ETIR__C_CTL_SETRB
:
2081 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2082 if (!(rel1
& RELC_SEC_BASE
))
2084 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2087 /* Augment relocation base: increment image location counter by offset
2088 arg: lw offset value. */
2089 case ETIR__C_CTL_AUGRB
:
2090 op1
= bfd_getl32 (ptr
);
2091 image_inc_ptr (abfd
, op1
);
2094 /* Define location: pop index, save location counter under index
2096 case ETIR__C_CTL_DFLOC
:
2097 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2098 if (rel1
!= RELC_NONE
)
2100 dst_define_location (abfd
, op1
);
2103 /* Set location: pop index, restore location counter from index
2105 case ETIR__C_CTL_STLOC
:
2106 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2107 if (rel1
!= RELC_NONE
)
2109 dst_restore_location (abfd
, op1
);
2112 /* Stack defined location: pop index, push location counter from index
2114 case ETIR__C_CTL_STKDL
:
2115 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2116 if (rel1
!= RELC_NONE
)
2118 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2121 case ETIR__C_OPR_NOP
: /* No-op. */
2124 case ETIR__C_OPR_ADD
: /* Add. */
2125 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2126 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2127 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2129 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2131 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2134 case ETIR__C_OPR_SUB
: /* Subtract. */
2135 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2136 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2137 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2139 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2141 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2142 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2145 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2147 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2150 case ETIR__C_OPR_MUL
: /* Multiply. */
2151 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2152 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2153 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2155 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2158 case ETIR__C_OPR_DIV
: /* Divide. */
2159 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2160 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2161 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2164 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2166 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2169 case ETIR__C_OPR_AND
: /* Logical AND. */
2170 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2171 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2172 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2174 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2177 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2178 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2179 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2180 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2182 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2185 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2186 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2187 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2188 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2190 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2193 case ETIR__C_OPR_NEG
: /* Negate. */
2194 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2195 if (rel1
!= RELC_NONE
)
2197 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2200 case ETIR__C_OPR_COM
: /* Complement. */
2201 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2202 if (rel1
!= RELC_NONE
)
2204 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2207 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2208 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2209 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2210 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2213 (*_bfd_error_handler
) (_("invalid use of %s with contexts"),
2214 _bfd_vms_etir_name (cmd
));
2217 if ((int)op2
< 0) /* Shift right. */
2219 else /* Shift left. */
2221 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2224 case ETIR__C_OPR_INSV
: /* Insert field. */
2225 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2226 case ETIR__C_OPR_ROT
: /* Rotate. */
2227 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2228 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2229 (*_bfd_error_handler
) (_("%s: not supported"),
2230 _bfd_vms_etir_name (cmd
));
2234 case ETIR__C_OPR_SEL
: /* Select. */
2235 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2237 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2240 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2241 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2242 _bfd_vms_push (abfd
, op1
, rel1
);
2247 (*_bfd_error_handler
) (_("reserved cmd %d"), cmd
);
2252 ptr
+= cmd_length
- 4;
2258 /* Process EDBG/ETBT record.
2259 Return TRUE on success, FALSE on error */
2262 vms_slurp_debug (bfd
*abfd
)
2264 asection
*section
= PRIV (dst_section
);
2266 if (section
== NULL
)
2268 /* We have no way to find out beforehand how much debug info there
2269 is in an object file, so pick an initial amount and grow it as
2271 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2274 section
= bfd_make_section (abfd
, "$DST$");
2277 if (!bfd_set_section_flags (abfd
, section
, flags
))
2279 PRIV (dst_section
) = section
;
2282 PRIV (image_section
) = section
;
2283 PRIV (image_offset
) = section
->size
;
2285 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2288 section
->size
= PRIV (image_offset
);
2292 /* Process EDBG record.
2293 Return TRUE on success, FALSE on error. */
2296 _bfd_vms_slurp_edbg (bfd
*abfd
)
2298 vms_debug2 ((2, "EDBG\n"));
2300 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2302 return vms_slurp_debug (abfd
);
2305 /* Process ETBT record.
2306 Return TRUE on success, FALSE on error. */
2309 _bfd_vms_slurp_etbt (bfd
*abfd
)
2311 vms_debug2 ((2, "ETBT\n"));
2313 abfd
->flags
|= HAS_LINENO
;
2315 return vms_slurp_debug (abfd
);
2318 /* Process EEOM record.
2319 Return TRUE on success, FALSE on error. */
2322 _bfd_vms_slurp_eeom (bfd
*abfd
)
2324 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2326 vms_debug2 ((2, "EEOM\n"));
2328 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2329 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2330 if (PRIV (eom_data
).eom_w_comcod
> 1)
2332 (*_bfd_error_handler
) (_("Object module NOT error-free !\n"));
2333 bfd_set_error (bfd_error_bad_value
);
2337 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2338 if (PRIV (recrd
.rec_size
) > 10)
2340 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2341 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2342 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2343 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2345 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2350 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2353 _bfd_vms_slurp_object_records (bfd
* abfd
)
2360 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2362 type
= _bfd_vms_get_object_record (abfd
);
2365 vms_debug2 ((2, "next_record failed\n"));
2372 err
= _bfd_vms_slurp_ehdr (abfd
);
2375 err
= _bfd_vms_slurp_eeom (abfd
);
2378 err
= _bfd_vms_slurp_egsd (abfd
);
2381 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2384 err
= _bfd_vms_slurp_edbg (abfd
);
2387 err
= _bfd_vms_slurp_etbt (abfd
);
2394 vms_debug2 ((2, "slurp type %d failed\n", type
));
2398 while (type
!= EOBJ__C_EEOM
);
2403 /* Initialize private data */
2405 vms_initialize (bfd
* abfd
)
2409 amt
= sizeof (struct vms_private_data_struct
);
2410 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2411 if (abfd
->tdata
.any
== NULL
)
2414 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2416 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2417 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2418 if (PRIV (stack
) == NULL
)
2424 bfd_release (abfd
, abfd
->tdata
.any
);
2425 abfd
->tdata
.any
= NULL
;
2429 /* Check the format for a file being read.
2430 Return a (bfd_target *) if it's an object file or zero if not. */
2432 static const struct bfd_target
*
2433 alpha_vms_object_p (bfd
*abfd
)
2435 void *tdata_save
= abfd
->tdata
.any
;
2436 unsigned int test_len
;
2439 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2441 /* Allocate alpha-vms specific data. */
2442 if (!vms_initialize (abfd
))
2445 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2446 goto err_wrong_format
;
2448 /* The first challenge with VMS is to discover the kind of the file.
2450 Image files (executable or shared images) are stored as a raw
2451 stream of bytes (like on UNIX), but there is no magic number.
2453 Object files are written with RMS (record management service), ie
2454 each records are preceeded by its length (on a word - 2 bytes), and
2455 padded for word-alignment. That would be simple but when files
2456 are transfered to a UNIX filesystem (using ftp), records are lost.
2457 Only the raw content of the records are transfered. Fortunately,
2458 the Alpha Object file format also store the length of the record
2459 in the records. Is that clear ? */
2461 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2462 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2463 4 bytes minor id, 4 bytes length). */
2466 /* Size the main buffer. */
2467 buf
= (unsigned char *) bfd_malloc (test_len
);
2470 PRIV (recrd
.buf
) = buf
;
2471 PRIV (recrd
.buf_size
) = test_len
;
2473 /* Initialize the record pointer. */
2474 PRIV (recrd
.rec
) = buf
;
2476 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2477 goto err_wrong_format
;
2479 /* Is it an image? */
2480 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2481 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2483 unsigned int to_read
;
2484 unsigned int read_so_far
;
2485 unsigned int remaining
;
2486 unsigned int eisd_offset
, eihs_offset
;
2488 /* Extract the header size. */
2489 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2491 /* The header size is 0 for DSF files. */
2492 if (PRIV (recrd
.rec_size
) == 0)
2493 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2495 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2497 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2501 PRIV (recrd
.buf
) = NULL
;
2504 PRIV (recrd
.buf
) = buf
;
2505 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2508 /* Read the remaining record. */
2509 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2510 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2511 read_so_far
= test_len
;
2513 while (remaining
> 0)
2515 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2516 goto err_wrong_format
;
2518 read_so_far
+= to_read
;
2519 remaining
-= to_read
;
2521 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2524 /* Reset the record pointer. */
2525 PRIV (recrd
.rec
) = buf
;
2527 vms_debug2 ((2, "file type is image\n"));
2529 if (_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
) != TRUE
)
2530 goto err_wrong_format
;
2532 if (_bfd_vms_slurp_eisd (abfd
, eisd_offset
) != TRUE
)
2533 goto err_wrong_format
;
2535 /* EIHS is optional. */
2536 if (eihs_offset
!= 0 && _bfd_vms_slurp_eihs (abfd
, eihs_offset
) != TRUE
)
2537 goto err_wrong_format
;
2543 /* Assume it's a module and adjust record pointer if necessary. */
2544 maybe_adjust_record_pointer_for_object (abfd
);
2546 /* But is it really a module? */
2547 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2548 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2550 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2551 goto err_wrong_format
;
2553 vms_debug2 ((2, "file type is module\n"));
2555 type
= bfd_getl16 (PRIV (recrd
.rec
));
2556 if (type
!= EOBJ__C_EMH
|| _bfd_vms_slurp_ehdr (abfd
) != TRUE
)
2557 goto err_wrong_format
;
2559 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
2560 goto err_wrong_format
;
2563 goto err_wrong_format
;
2566 /* Set arch_info to alpha. */
2568 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2569 goto err_wrong_format
;
2574 bfd_set_error (bfd_error_wrong_format
);
2577 if (PRIV (recrd
.buf
))
2578 free (PRIV (recrd
.buf
));
2579 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2580 bfd_release (abfd
, abfd
->tdata
.any
);
2581 abfd
->tdata
.any
= tdata_save
;
2587 /* Write an EMH/MHD record. */
2590 _bfd_vms_write_emh (bfd
*abfd
)
2592 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2594 _bfd_vms_output_alignment (recwr
, 2);
2597 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2598 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
2599 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
2600 _bfd_vms_output_long (recwr
, 0);
2601 _bfd_vms_output_long (recwr
, 0);
2602 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
2604 /* Create module name from filename. */
2605 if (bfd_get_filename (abfd
) != 0)
2607 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2608 _bfd_vms_output_counted (recwr
, module
);
2612 _bfd_vms_output_counted (recwr
, "NONAME");
2614 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
2615 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
2616 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
2617 _bfd_vms_output_end (abfd
, recwr
);
2620 /* Write an EMH/LMN record. */
2623 _bfd_vms_write_lmn (bfd
*abfd
, const char *name
)
2626 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2627 unsigned int ver
= BFD_VERSION
/ 10000;
2630 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
2631 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
2632 snprintf (version
, sizeof (version
), "%s %d.%d.%d", name
,
2633 ver
/ 10000, (ver
/ 100) % 100, ver
% 100);
2634 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
2635 _bfd_vms_output_end (abfd
, recwr
);
2639 /* Write eom record for bfd abfd. Return FALSE on error. */
2642 _bfd_vms_write_eeom (bfd
*abfd
)
2644 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
2646 vms_debug2 ((2, "vms_write_eeom\n"));
2648 _bfd_vms_output_alignment (recwr
, 2);
2650 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
2651 _bfd_vms_output_long (recwr
, PRIV (vms_linkage_index
+ 1) >> 1);
2652 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
2653 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
2655 if ((abfd
->flags
& EXEC_P
) == 0
2656 && bfd_get_start_address (abfd
) != (bfd_vma
)-1)
2660 section
= bfd_get_section_by_name (abfd
, ".link");
2663 bfd_set_error (bfd_error_nonrepresentable_section
);
2666 _bfd_vms_output_short (recwr
, 0);
2667 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
2668 _bfd_vms_output_long (recwr
,
2669 (unsigned long) bfd_get_start_address (abfd
));
2670 _bfd_vms_output_long (recwr
, 0);
2673 _bfd_vms_output_end (abfd
, recwr
);
2678 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2680 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2683 if (vec
->max_el
== 0)
2686 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2691 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2695 /* Bump ABFD file position to next block. */
2698 alpha_vms_file_position_block (bfd
*abfd
)
2701 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2702 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2705 /* Convert from internal structure SRC to external structure DST. */
2708 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2709 struct vms_eisd
*dst
)
2711 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2712 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2713 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2714 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2716 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2717 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2718 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2719 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2720 dst
->pfc
= src
->u
.eisd
.pfc
;
2721 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2722 dst
->type
= src
->u
.eisd
.type
;
2724 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2726 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2727 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2728 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2732 /* Append EISD to the list of extra eisd for ABFD. */
2735 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2738 if (PRIV (gbl_eisd_head
) == NULL
)
2739 PRIV (gbl_eisd_head
) = eisd
;
2741 PRIV (gbl_eisd_tail
)->next
= eisd
;
2742 PRIV (gbl_eisd_tail
) = eisd
;
2745 /* Create an EISD for shared image SHRIMG.
2746 Return FALSE in case of error. */
2749 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2751 struct vms_internal_eisd_map
*eisd
;
2754 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2755 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2761 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2765 /* Fill the fields. */
2766 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2767 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2768 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2769 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2770 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2771 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2772 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2773 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2774 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2775 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2777 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2778 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2779 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2781 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2783 /* Append it to the list. */
2784 alpha_vms_append_extra_eisd (abfd
, eisd
);
2789 /* Create an EISD for section SEC.
2790 Return FALSE in case of failure. */
2793 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2795 struct vms_internal_eisd_map
*eisd
;
2797 /* Only for allocating section. */
2798 if (!(sec
->flags
& SEC_ALLOC
))
2801 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2802 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2805 vms_section_data (sec
)->eisd
= eisd
;
2807 /* Fill the fields. */
2808 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2809 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2810 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2811 eisd
->u
.eisd
.secsize
=
2812 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2813 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2814 eisd
->u
.eisd
.flags
= 0;
2815 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2816 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2817 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2818 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2820 if (sec
->flags
& SEC_CODE
)
2821 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2822 if (!(sec
->flags
& SEC_READONLY
))
2823 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2825 /* If relocations or fixup will be applied, make this isect writeable. */
2826 if (sec
->flags
& SEC_RELOC
)
2827 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2829 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
2831 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
2832 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
2834 if (sec
->flags
& SEC_LINKER_CREATED
)
2836 if (strcmp (sec
->name
, "$FIXUP$") == 0)
2837 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
2840 /* Append it to the list. */
2842 if (PRIV (eisd_head
) == NULL
)
2843 PRIV (eisd_head
) = eisd
;
2845 PRIV (eisd_tail
)->next
= eisd
;
2846 PRIV (eisd_tail
) = eisd
;
2851 /* Layout executable ABFD and write it to the disk.
2852 Return FALSE in case of failure. */
2855 alpha_vms_write_exec (bfd
*abfd
)
2857 struct vms_eihd eihd
;
2858 struct vms_eiha
*eiha
;
2859 struct vms_eihi
*eihi
;
2860 struct vms_eihs
*eihs
= NULL
;
2862 struct vms_internal_eisd_map
*first_eisd
;
2863 struct vms_internal_eisd_map
*eisd
;
2866 file_ptr gst_filepos
= 0;
2867 unsigned int lnkflags
= 0;
2869 /* Build the EIHD. */
2870 PRIV (file_pos
) = EIHD__C_LENGTH
;
2872 memset (&eihd
, 0, sizeof (eihd
));
2873 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
2875 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
2876 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
2878 bfd_putl32 (sizeof (eihd
), eihd
.size
);
2879 bfd_putl32 (0, eihd
.isdoff
);
2880 bfd_putl32 (0, eihd
.activoff
);
2881 bfd_putl32 (0, eihd
.symdbgoff
);
2882 bfd_putl32 (0, eihd
.imgidoff
);
2883 bfd_putl32 (0, eihd
.patchoff
);
2884 bfd_putl64 (0, eihd
.iafva
);
2885 bfd_putl32 (0, eihd
.version_array_off
);
2887 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
2888 bfd_putl32 (0, eihd
.subtype
);
2890 bfd_putl32 (0, eihd
.imgiocnt
);
2891 bfd_putl32 (-1, eihd
.privreqs
);
2892 bfd_putl32 (-1, eihd
.privreqs
+ 4);
2894 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2896 bfd_putl32 (0, eihd
.ident
);
2897 bfd_putl32 (0, eihd
.sysver
);
2900 bfd_putl32 (0, eihd
.symvect_size
);
2901 bfd_putl32 (16, eihd
.virt_mem_block_size
);
2902 bfd_putl32 (0, eihd
.ext_fixup_off
);
2903 bfd_putl32 (0, eihd
.noopt_psect_off
);
2904 bfd_putl32 (-1, eihd
.alias
);
2907 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
2908 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
2909 PRIV (file_pos
) += sizeof (struct vms_eiha
);
2911 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
2912 bfd_putl32 (0, eiha
->spare
);
2913 bfd_putl64 (PRIV (transfer_address
[0]), eiha
->tfradr1
);
2914 bfd_putl64 (PRIV (transfer_address
[1]), eiha
->tfradr2
);
2915 bfd_putl64 (PRIV (transfer_address
[2]), eiha
->tfradr3
);
2916 bfd_putl64 (PRIV (transfer_address
[3]), eiha
->tfradr4
);
2917 bfd_putl64 (0, eiha
->inishr
);
2920 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
2921 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
2922 PRIV (file_pos
) += sizeof (struct vms_eihi
);
2924 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
2925 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
2930 /* Set module name. */
2931 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2932 len
= strlen (module
);
2933 if (len
> sizeof (eihi
->imgnam
) - 1)
2934 len
= sizeof (eihi
->imgnam
) - 1;
2935 eihi
->imgnam
[0] = len
;
2936 memcpy (eihi
->imgnam
+ 1, module
, len
);
2944 vms_get_time (&hi
, &lo
);
2945 bfd_putl32 (lo
, eihi
->linktime
+ 0);
2946 bfd_putl32 (hi
, eihi
->linktime
+ 4);
2949 eihi
->linkid
[0] = 0;
2950 eihi
->imgbid
[0] = 0;
2953 dst
= PRIV (dst_section
);
2954 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
2955 if (dst
!= NULL
&& dst
->size
!= 0)
2957 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
2958 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
2959 PRIV (file_pos
) += sizeof (struct vms_eihs
);
2961 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
2962 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
2963 bfd_putl32 (0, eihs
->dstvbn
);
2964 bfd_putl32 (0, eihs
->dstsize
);
2965 bfd_putl32 (0, eihs
->gstvbn
);
2966 bfd_putl32 (0, eihs
->gstsize
);
2967 bfd_putl32 (0, eihs
->dmtvbn
);
2968 bfd_putl32 (0, eihs
->dmtsize
);
2971 /* One EISD per section. */
2972 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2974 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
2978 /* Merge section EIDS which extra ones. */
2979 if (PRIV (eisd_tail
))
2980 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
2982 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
2983 if (PRIV (gbl_eisd_tail
))
2984 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
2986 first_eisd
= PRIV (eisd_head
);
2988 /* Add end of eisd. */
2991 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
2994 eisd
->u
.eisd
.majorid
= 0;
2995 eisd
->u
.eisd
.minorid
= 0;
2996 eisd
->u
.eisd
.eisdsize
= 0;
2997 alpha_vms_append_extra_eisd (abfd
, eisd
);
3000 /* Place EISD in the file. */
3001 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
3003 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
3005 /* First block is a little bit special: there is a word at the end. */
3006 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
3008 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
3009 alpha_vms_file_position_block (abfd
);
3011 eisd
->file_pos
= PRIV (file_pos
);
3012 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
3014 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
3015 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
3018 if (first_eisd
!= NULL
)
3020 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
3021 /* Real size of end of eisd marker. */
3022 PRIV (file_pos
) += EISD__K_LENEND
;
3025 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
3026 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
3029 /* Place sections. */
3030 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3032 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
3035 eisd
= vms_section_data (sec
)->eisd
;
3037 /* Align on a block. */
3038 alpha_vms_file_position_block (abfd
);
3039 sec
->filepos
= PRIV (file_pos
);
3042 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
3044 PRIV (file_pos
) += sec
->size
;
3048 if (eihs
!= NULL
&& dst
!= NULL
)
3050 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
3051 bfd_putl32 (dst
->size
, eihs
->dstsize
);
3055 lnkflags
|= EIHD__M_DBGDMT
;
3056 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
3057 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
3059 if (PRIV (gsd_sym_count
) != 0)
3061 alpha_vms_file_position_block (abfd
);
3062 gst_filepos
= PRIV (file_pos
);
3063 bfd_putl32 ((gst_filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->gstvbn
);
3064 bfd_putl32 ((PRIV (gsd_sym_count
) + 4) / 5 + 4, eihs
->gstsize
);
3068 /* Write EISD in hdr. */
3069 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
3071 alpha_vms_swap_eisd_out
3072 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
3074 /* Write first block. */
3075 bfd_putl32 (lnkflags
, eihd
.lnkflags
);
3076 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
3079 /* Write remaining eisd. */
3082 unsigned char blk
[VMS_BLOCK_SIZE
];
3083 struct vms_internal_eisd_map
*next_eisd
;
3085 memset (blk
, 0xff, sizeof (blk
));
3086 while (eisd
!= NULL
)
3088 alpha_vms_swap_eisd_out
3090 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
3092 next_eisd
= eisd
->next
;
3093 if (next_eisd
== NULL
3094 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
3095 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
3097 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
3100 memset (blk
, 0xff, sizeof (blk
));
3106 /* Write sections. */
3107 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
3109 unsigned char blk
[VMS_BLOCK_SIZE
];
3112 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
3114 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
3118 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
3119 if (len
!= VMS_BLOCK_SIZE
)
3121 memset (blk
, 0, len
);
3122 if (bfd_bwrite (blk
, len
, abfd
) != len
)
3128 if (gst_filepos
!= 0)
3130 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3133 _bfd_vms_write_emh (abfd
);
3134 _bfd_vms_write_lmn (abfd
, "GNU LD");
3136 /* PSC for the absolute section. */
3137 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3138 _bfd_vms_output_long (recwr
, 0);
3139 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3140 _bfd_vms_output_short (recwr
, 0);
3141 _bfd_vms_output_short (recwr
, EGPS__V_PIC
| EGPS__V_LIB
| EGPS__V_RD
);
3142 _bfd_vms_output_long (recwr
, 0);
3143 _bfd_vms_output_counted (recwr
, ".$$ABS$$.");
3144 _bfd_vms_output_end_subrec (recwr
);
3145 _bfd_vms_output_end (abfd
, recwr
);
3147 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
3149 struct vms_symbol_entry
*sym
= PRIV (syms
)[i
];
3155 _bfd_vms_output_alignment (recwr
, 8);
3156 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3157 _bfd_vms_output_long (recwr
, 0);
3159 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYMG
);
3160 _bfd_vms_output_short (recwr
, 0); /* Data type, alignment. */
3161 _bfd_vms_output_short (recwr
, sym
->flags
);
3163 if (sym
->code_section
)
3164 ep
= alpha_vms_get_sym_value (sym
->code_section
, sym
->code_value
);
3167 BFD_ASSERT (sym
->code_value
== 0);
3170 val
= alpha_vms_get_sym_value (sym
->section
, sym
->value
);
3171 _bfd_vms_output_quad
3172 (recwr
, sym
->typ
== EGSD__C_SYMG
? sym
->symbol_vector
: val
);
3173 _bfd_vms_output_quad (recwr
, ep
);
3174 _bfd_vms_output_quad (recwr
, val
);
3175 _bfd_vms_output_long (recwr
, 0);
3176 _bfd_vms_output_counted (recwr
, sym
->name
);
3177 _bfd_vms_output_end_subrec (recwr
);
3179 _bfd_vms_output_end (abfd
, recwr
);
3182 _bfd_vms_output_end (abfd
, recwr
);
3184 if (!_bfd_vms_write_eeom (abfd
))
3192 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3195 _bfd_vms_write_egsd (bfd
*abfd
)
3199 unsigned int symnum
;
3201 flagword new_flags
, old_flags
;
3202 int abs_section_index
= -1;
3203 unsigned int target_index
= 0;
3204 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3206 vms_debug2 ((2, "vms_write_egsd\n"));
3208 /* Egsd is quadword aligned. */
3209 _bfd_vms_output_alignment (recwr
, 8);
3211 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3212 _bfd_vms_output_long (recwr
, 0);
3214 /* Number sections. */
3215 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3217 if (section
->flags
& SEC_DEBUGGING
)
3219 if (!strcmp (section
->name
, ".vmsdebug"))
3221 section
->flags
|= SEC_DEBUGGING
;
3224 section
->target_index
= target_index
++;
3227 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3229 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3230 section
->target_index
, section
->name
, (int)section
->size
));
3232 /* Don't write out the VMS debug info section since it is in the
3233 ETBT and EDBG sections in etir. */
3234 if (section
->flags
& SEC_DEBUGGING
)
3237 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3238 if (_bfd_vms_output_check (recwr
, 64) < 0)
3240 _bfd_vms_output_end (abfd
, recwr
);
3241 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3242 _bfd_vms_output_long (recwr
, 0);
3245 /* Don't know if this is necessary for the linker but for now it keeps
3246 vms_slurp_gsd happy. */
3247 sname
= section
->name
;
3250 /* Remove leading dot. */
3252 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3253 sname
= EVAX_CODE_NAME
;
3254 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3255 sname
= EVAX_DATA_NAME
;
3256 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3257 sname
= EVAX_BSS_NAME
;
3258 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3259 sname
= EVAX_LINK_NAME
;
3260 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3261 sname
= EVAX_READONLY_NAME
;
3262 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3263 sname
= EVAX_LITERAL_NAME
;
3264 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3265 sname
= EVAX_LITERALS_NAME
;
3266 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3267 sname
= EVAX_COMMON_NAME
;
3268 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3269 sname
= EVAX_LOCAL_NAME
;
3272 if (bfd_is_com_section (section
))
3273 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3274 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3276 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3279 /* Modify them as directed. */
3280 if (section
->flags
& SEC_READONLY
)
3281 new_flags
&= ~EGPS__V_WRT
;
3283 new_flags
&= ~vms_section_data (section
)->no_flags
;
3284 new_flags
|= vms_section_data (section
)->flags
;
3286 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3287 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3288 new_flags
, (unsigned long)section
->size
));
3290 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3291 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3292 _bfd_vms_output_short (recwr
, new_flags
);
3293 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3294 _bfd_vms_output_counted (recwr
, sname
);
3295 _bfd_vms_output_end_subrec (recwr
);
3297 /* If the section is an obsolute one, remind its index as it will be
3298 used later for absolute symbols. */
3299 if ((new_flags
& EGPS__V_REL
) == 0 && abs_section_index
< 0)
3300 abs_section_index
= section
->target_index
;
3303 /* Output symbols. */
3304 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3306 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3308 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3310 symbol
= abfd
->outsymbols
[symnum
];
3311 old_flags
= symbol
->flags
;
3313 /* Work-around a missing feature: consider __main as the main entry
3315 if (symbol
->name
[0] == '_' && strcmp (symbol
->name
, "__main") == 0)
3316 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3318 /* Only put in the GSD the global and the undefined symbols. */
3319 if (old_flags
& BSF_FILE
)
3322 if ((old_flags
& BSF_GLOBAL
) == 0 && !bfd_is_und_section (symbol
->section
))
3324 /* If the LIB$INITIIALIZE section is present, add a reference to
3325 LIB$INITIALIZE symbol. FIXME: this should be done explicitely
3326 in the assembly file. */
3327 if (!((old_flags
& BSF_SECTION_SYM
) != 0
3328 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3332 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
3333 bytes for a possible ABS section. */
3334 if (_bfd_vms_output_check (recwr
, 80 + 16) < 0)
3336 _bfd_vms_output_end (abfd
, recwr
);
3337 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3338 _bfd_vms_output_long (recwr
, 0);
3341 if ((old_flags
& BSF_GLOBAL
) != 0
3342 && bfd_is_abs_section (symbol
->section
)
3343 && abs_section_index
<= 0)
3345 /* Create an absolute section if none was defined. It is highly
3346 unlikely that the name $ABS$ clashes with a user defined
3347 non-absolute section name. */
3348 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3349 _bfd_vms_output_short (recwr
, 4);
3350 _bfd_vms_output_short (recwr
, EGPS__V_SHR
);
3351 _bfd_vms_output_long (recwr
, 0);
3352 _bfd_vms_output_counted (recwr
, "$ABS$");
3353 _bfd_vms_output_end_subrec (recwr
);
3355 abs_section_index
= target_index
++;
3358 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3360 /* Data type, alignment. */
3361 _bfd_vms_output_short (recwr
, 0);
3365 if (old_flags
& BSF_WEAK
)
3366 new_flags
|= EGSY__V_WEAK
;
3367 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3368 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3370 if (old_flags
& BSF_FUNCTION
)
3372 new_flags
|= EGSY__V_NORM
;
3373 new_flags
|= EGSY__V_REL
;
3375 if (old_flags
& BSF_GLOBAL
)
3377 new_flags
|= EGSY__V_DEF
;
3378 if (!bfd_is_abs_section (symbol
->section
))
3379 new_flags
|= EGSY__V_REL
;
3381 _bfd_vms_output_short (recwr
, new_flags
);
3383 if (old_flags
& BSF_GLOBAL
)
3385 /* Symbol definition. */
3386 bfd_vma code_address
= 0;
3387 unsigned long ca_psindx
= 0;
3388 unsigned long psindx
;
3390 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3395 ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3396 code_address
= sym
->value
;
3397 ca_psindx
= sym
->section
->target_index
;
3399 if (bfd_is_abs_section (symbol
->section
))
3400 psindx
= abs_section_index
;
3402 psindx
= symbol
->section
->target_index
;
3404 _bfd_vms_output_quad (recwr
, symbol
->value
);
3405 _bfd_vms_output_quad (recwr
, code_address
);
3406 _bfd_vms_output_long (recwr
, ca_psindx
);
3407 _bfd_vms_output_long (recwr
, psindx
);
3409 _bfd_vms_output_counted (recwr
, symbol
->name
);
3411 _bfd_vms_output_end_subrec (recwr
);
3414 _bfd_vms_output_alignment (recwr
, 8);
3415 _bfd_vms_output_end (abfd
, recwr
);
3420 /* Write object header for bfd abfd. Return FALSE on error. */
3423 _bfd_vms_write_ehdr (bfd
*abfd
)
3426 unsigned int symnum
;
3427 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3429 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3431 _bfd_vms_output_alignment (recwr
, 2);
3433 _bfd_vms_write_emh (abfd
);
3434 _bfd_vms_write_lmn (abfd
, "GNU AS");
3437 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3438 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3440 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3442 symbol
= abfd
->outsymbols
[symnum
];
3444 if (symbol
->flags
& BSF_FILE
)
3446 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3447 (int) strlen (symbol
->name
));
3452 if (symnum
== abfd
->symcount
)
3453 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3455 _bfd_vms_output_end (abfd
, recwr
);
3458 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3459 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3460 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3461 _bfd_vms_output_end (abfd
, recwr
);
3464 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3465 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3466 _bfd_vms_output_dump (recwr
,
3467 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3469 _bfd_vms_output_end (abfd
, recwr
);
3474 /* Part 4.6, relocations. */
3477 /* WRITE ETIR SECTION
3479 This is still under construction and therefore not documented. */
3481 /* Close the etir/etbt record. */
3484 end_etir_record (bfd
* abfd
)
3486 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3488 _bfd_vms_output_end (abfd
, recwr
);
3492 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3494 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3496 if (section
->flags
& SEC_DEBUGGING
)
3498 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3502 /* Push start offset. */
3503 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3504 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3505 _bfd_vms_output_end_subrec (recwr
);
3508 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3509 _bfd_vms_output_end_subrec (recwr
);
3514 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3518 /* Push start offset. */
3519 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3520 _bfd_vms_output_long (recwr
, (unsigned long) section
->target_index
);
3521 _bfd_vms_output_quad (recwr
, offset
);
3522 _bfd_vms_output_end_subrec (recwr
);
3524 /* Start = pop (). */
3525 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3526 _bfd_vms_output_end_subrec (recwr
);
3531 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3532 address VADDR in section specified by SEC_INDEX and NAME. */
3535 sto_imm (bfd
*abfd
, asection
*section
,
3536 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3539 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3542 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3543 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3548 /* Try all the rest. */
3551 if (_bfd_vms_output_check (recwr
, size
) < 0)
3553 /* Doesn't fit, split ! */
3554 end_etir_record (abfd
);
3556 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3558 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3559 if (size
> ssize
) /* more than what's left ? */
3563 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3564 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3565 _bfd_vms_output_dump (recwr
, cptr
, size
);
3566 _bfd_vms_output_end_subrec (recwr
);
3569 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3570 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3580 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3582 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3584 /* Not enough room in this record. Close it and open a new one. */
3585 end_etir_record (abfd
);
3586 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3590 /* Return whether RELOC must be deferred till the end. */
3593 defer_reloc_p (arelent
*reloc
)
3595 switch (reloc
->howto
->type
)
3608 /* Write section contents for bfd abfd. Return FALSE on error. */
3611 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3614 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3616 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3618 _bfd_vms_output_alignment (recwr
, 4);
3620 PRIV (vms_linkage_index
) = 0;
3622 for (section
= abfd
->sections
; section
; section
= section
->next
)
3624 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3625 section
->target_index
, section
->name
, (int) (section
->size
)));
3627 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3628 || bfd_is_com_section (section
))
3631 if (!section
->contents
)
3633 bfd_set_error (bfd_error_no_contents
);
3637 start_etir_or_etbt_record (abfd
, section
, 0);
3639 if (section
->flags
& SEC_RELOC
)
3641 bfd_vma curr_addr
= 0;
3642 unsigned char *curr_data
= section
->contents
;
3644 int pass2_needed
= 0;
3645 int pass2_in_progress
= 0;
3648 if (section
->reloc_count
== 0)
3649 (*_bfd_error_handler
)
3650 (_("SEC_RELOC with no relocs in section %s"), section
->name
);
3655 int i
= section
->reloc_count
;
3656 arelent
**rptr
= section
->orelocation
;
3657 _bfd_vms_debug (4, "%d relocations:\n", i
);
3660 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3661 "addr %08lx, off %08lx, len %d: %s\n",
3662 (*(*rptr
)->sym_ptr_ptr
)->name
,
3663 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3664 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3665 (unsigned long)(*rptr
)->address
,
3666 (unsigned long)(*rptr
)->addend
,
3667 bfd_get_reloc_size ((*rptr
)->howto
),
3668 ( *rptr
)->howto
->name
);
3675 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3677 struct evax_private_udata_struct
*udata
;
3678 arelent
*rptr
= section
->orelocation
[irel
];
3679 bfd_vma addr
= rptr
->address
;
3680 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3681 asection
*sec
= sym
->section
;
3682 bfd_boolean defer
= defer_reloc_p (rptr
);
3685 if (pass2_in_progress
)
3687 /* Non-deferred relocs have already been output. */
3693 /* Deferred relocs must be output at the very end. */
3700 /* Regular relocs are intertwined with binary data. */
3701 if (curr_addr
> addr
)
3702 (*_bfd_error_handler
) (_("Size error in section %s"),
3704 size
= addr
- curr_addr
;
3705 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3710 size
= bfd_get_reloc_size (rptr
->howto
);
3712 switch (rptr
->howto
->type
)
3714 case ALPHA_R_IGNORE
:
3717 case ALPHA_R_REFLONG
:
3718 if (bfd_is_und_section (sym
->section
))
3720 bfd_vma addend
= rptr
->addend
;
3721 slen
= strlen ((char *) sym
->name
);
3722 etir_output_check (abfd
, section
, curr_addr
, slen
);
3725 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3726 _bfd_vms_output_counted (recwr
, sym
->name
);
3727 _bfd_vms_output_end_subrec (recwr
);
3728 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3729 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3730 _bfd_vms_output_end_subrec (recwr
);
3731 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3732 _bfd_vms_output_end_subrec (recwr
);
3733 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3734 _bfd_vms_output_end_subrec (recwr
);
3738 _bfd_vms_output_begin_subrec
3739 (recwr
, ETIR__C_STO_GBL_LW
);
3740 _bfd_vms_output_counted (recwr
, sym
->name
);
3741 _bfd_vms_output_end_subrec (recwr
);
3744 else if (bfd_is_abs_section (sym
->section
))
3746 etir_output_check (abfd
, section
, curr_addr
, 16);
3747 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3748 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3749 _bfd_vms_output_end_subrec (recwr
);
3750 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3751 _bfd_vms_output_end_subrec (recwr
);
3755 etir_output_check (abfd
, section
, curr_addr
, 32);
3756 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3757 _bfd_vms_output_long (recwr
,
3758 (unsigned long) sec
->target_index
);
3759 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3760 _bfd_vms_output_end_subrec (recwr
);
3761 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3762 says that we should have a ETIR__C_STO_OFF here.
3763 But the relocation would not be BFD_RELOC_32 then.
3764 This case is very likely unreachable. */
3765 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3766 _bfd_vms_output_end_subrec (recwr
);
3770 case ALPHA_R_REFQUAD
:
3771 if (bfd_is_und_section (sym
->section
))
3773 bfd_vma addend
= rptr
->addend
;
3774 slen
= strlen ((char *) sym
->name
);
3775 etir_output_check (abfd
, section
, curr_addr
, slen
);
3778 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3779 _bfd_vms_output_counted (recwr
, sym
->name
);
3780 _bfd_vms_output_end_subrec (recwr
);
3781 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3782 _bfd_vms_output_quad (recwr
, addend
);
3783 _bfd_vms_output_end_subrec (recwr
);
3784 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3785 _bfd_vms_output_end_subrec (recwr
);
3786 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3787 _bfd_vms_output_end_subrec (recwr
);
3791 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3792 _bfd_vms_output_counted (recwr
, sym
->name
);
3793 _bfd_vms_output_end_subrec (recwr
);
3796 else if (bfd_is_abs_section (sym
->section
))
3798 etir_output_check (abfd
, section
, curr_addr
, 16);
3799 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3800 _bfd_vms_output_quad (recwr
, sym
->value
);
3801 _bfd_vms_output_end_subrec (recwr
);
3802 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3803 _bfd_vms_output_end_subrec (recwr
);
3807 etir_output_check (abfd
, section
, curr_addr
, 32);
3808 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3809 _bfd_vms_output_long (recwr
,
3810 (unsigned long) sec
->target_index
);
3811 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3812 _bfd_vms_output_end_subrec (recwr
);
3813 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3814 _bfd_vms_output_end_subrec (recwr
);
3819 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3822 case ALPHA_R_LINKAGE
:
3823 etir_output_check (abfd
, section
, curr_addr
, 64);
3824 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
3825 _bfd_vms_output_long
3826 (recwr
, (unsigned long) rptr
->addend
);
3827 if (rptr
->addend
> PRIV (vms_linkage_index
))
3828 PRIV (vms_linkage_index
) = rptr
->addend
;
3829 _bfd_vms_output_counted (recwr
, sym
->name
);
3830 _bfd_vms_output_byte (recwr
, 0);
3831 _bfd_vms_output_end_subrec (recwr
);
3834 case ALPHA_R_CODEADDR
:
3835 slen
= strlen ((char *) sym
->name
);
3836 etir_output_check (abfd
, section
, curr_addr
, slen
);
3837 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
3838 _bfd_vms_output_counted (recwr
, sym
->name
);
3839 _bfd_vms_output_end_subrec (recwr
);
3844 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3845 etir_output_check (abfd
, section
, curr_addr
,
3846 32 + 1 + strlen (udata
->origname
));
3847 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
3848 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3849 _bfd_vms_output_long
3850 (recwr
, (unsigned long) section
->target_index
);
3851 _bfd_vms_output_quad (recwr
, rptr
->address
);
3852 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
3853 _bfd_vms_output_long
3854 (recwr
, (unsigned long) section
->target_index
);
3855 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3856 _bfd_vms_output_counted (recwr
, udata
->origname
);
3857 _bfd_vms_output_end_subrec (recwr
);
3861 (*_bfd_error_handler
) (_("Spurious ALPHA_R_BSR reloc"));
3866 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3867 etir_output_check (abfd
, section
, curr_addr
,
3868 32 + 1 + strlen (udata
->origname
));
3869 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
3870 _bfd_vms_output_long
3871 (recwr
, (unsigned long) udata
->lkindex
+ 1);
3872 _bfd_vms_output_long
3873 (recwr
, (unsigned long) section
->target_index
);
3874 _bfd_vms_output_quad (recwr
, rptr
->address
);
3875 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
3876 _bfd_vms_output_long
3877 (recwr
, (unsigned long) udata
->bsym
->section
->target_index
);
3878 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3879 _bfd_vms_output_counted (recwr
, udata
->origname
);
3880 _bfd_vms_output_end_subrec (recwr
);
3885 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3886 etir_output_check (abfd
, section
, curr_addr
,
3887 32 + 1 + strlen (udata
->origname
));
3888 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
3889 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3890 _bfd_vms_output_long
3891 (recwr
, (unsigned long) section
->target_index
);
3892 _bfd_vms_output_quad (recwr
, rptr
->address
);
3893 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
3894 _bfd_vms_output_long
3895 (recwr
, (unsigned long) section
->target_index
);
3896 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3897 _bfd_vms_output_counted (recwr
, udata
->origname
);
3898 _bfd_vms_output_end_subrec (recwr
);
3902 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
3909 } /* End of relocs loop. */
3911 if (!pass2_in_progress
)
3913 /* Output rest of section. */
3914 if (curr_addr
> section
->size
)
3915 (*_bfd_error_handler
) (_("Size error in section %s"),
3917 size
= section
->size
- curr_addr
;
3918 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3924 pass2_in_progress
= 1;
3930 else /* (section->flags & SEC_RELOC) */
3931 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
3933 end_etir_record (abfd
);
3936 _bfd_vms_output_alignment (recwr
, 2);
3940 /* Write cached information into a file being written, at bfd_close. */
3943 alpha_vms_write_object_contents (bfd
*abfd
)
3945 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
3947 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3949 return alpha_vms_write_exec (abfd
);
3953 if (abfd
->section_count
> 0) /* we have sections */
3955 if (_bfd_vms_write_ehdr (abfd
) != TRUE
)
3957 if (_bfd_vms_write_egsd (abfd
) != TRUE
)
3959 if (_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
) != TRUE
)
3961 if (_bfd_vms_write_eeom (abfd
) != TRUE
)
3968 /* Debug stuff: nearest line. */
3970 #define SET_MODULE_PARSED(m) \
3971 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
3972 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
3974 /* Build a new module for the specified BFD. */
3976 static struct module
*
3977 new_module (bfd
*abfd
)
3979 struct module
*module
3980 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
3981 module
->file_table_count
= 16; /* Arbitrary. */
3983 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
3987 /* Parse debug info for a module and internalize it. */
3990 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
3993 unsigned char *maxptr
= ptr
+ length
;
3994 unsigned char *src_ptr
, *pcl_ptr
;
3995 unsigned int prev_linum
= 0, curr_linenum
= 0;
3996 bfd_vma prev_pc
= 0, curr_pc
= 0;
3997 struct srecinfo
*curr_srec
, *srec
;
3998 struct lineinfo
*curr_line
, *line
;
3999 struct funcinfo
*funcinfo
;
4001 /* Initialize tables with zero element. */
4002 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4003 module
->srec_table
= curr_srec
;
4005 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4006 module
->line_table
= curr_line
;
4008 while (length
== -1 || ptr
< maxptr
)
4010 /* The first byte is not counted in the recorded length. */
4011 int rec_length
= bfd_getl16 (ptr
) + 1;
4012 int rec_type
= bfd_getl16 (ptr
+ 2);
4014 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
4016 if (length
== -1 && rec_type
== DST__K_MODEND
)
4023 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
);
4030 vms_debug2 ((3, "module: %s\n", module
->name
));
4037 funcinfo
= (struct funcinfo
*)
4038 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4040 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
);
4041 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4042 funcinfo
->next
= module
->func_table
;
4043 module
->func_table
= funcinfo
;
4045 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4046 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4050 module
->func_table
->high
= module
->func_table
->low
4051 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4053 if (module
->func_table
->high
> module
->high
)
4054 module
->high
= module
->func_table
->high
;
4056 vms_debug2 ((3, "end routine\n"));
4060 vms_debug2 ((3, "prologue\n"));
4064 vms_debug2 ((3, "epilog\n"));
4068 vms_debug2 ((3, "block\n"));
4072 vms_debug2 ((3, "end block\n"));
4076 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4078 vms_debug2 ((3, "source info\n"));
4080 while (src_ptr
< ptr
+ rec_length
)
4082 int cmd
= src_ptr
[0], cmd_length
, data
;
4086 case DST__K_SRC_DECLFILE
:
4089 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4091 = _bfd_vms_save_counted_string (src_ptr
4092 + DST_S_B_SRC_DF_FILENAME
);
4094 while (fileid
>= module
->file_table_count
)
4096 module
->file_table_count
*= 2;
4098 = bfd_realloc (module
->file_table
,
4099 module
->file_table_count
4100 * sizeof (struct fileinfo
));
4103 module
->file_table
[fileid
].name
= filename
;
4104 module
->file_table
[fileid
].srec
= 1;
4105 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4106 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4107 fileid
, module
->file_table
[fileid
].name
));
4111 case DST__K_SRC_DEFLINES_B
:
4112 /* Perform the association and set the next higher index
4114 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4115 srec
= (struct srecinfo
*)
4116 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4117 srec
->line
= curr_srec
->line
+ data
;
4118 srec
->srec
= curr_srec
->srec
+ data
;
4119 srec
->sfile
= curr_srec
->sfile
;
4120 curr_srec
->next
= srec
;
4123 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4126 case DST__K_SRC_DEFLINES_W
:
4127 /* Perform the association and set the next higher index
4129 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4130 srec
= (struct srecinfo
*)
4131 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4132 srec
->line
= curr_srec
->line
+ data
;
4133 srec
->srec
= curr_srec
->srec
+ data
,
4134 srec
->sfile
= curr_srec
->sfile
;
4135 curr_srec
->next
= srec
;
4138 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4141 case DST__K_SRC_INCRLNUM_B
:
4142 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4143 curr_srec
->line
+= data
;
4145 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4148 case DST__K_SRC_SETFILE
:
4149 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4150 curr_srec
->sfile
= data
;
4151 curr_srec
->srec
= module
->file_table
[data
].srec
;
4153 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4156 case DST__K_SRC_SETLNUM_L
:
4157 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4158 curr_srec
->line
= data
;
4160 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4163 case DST__K_SRC_SETLNUM_W
:
4164 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4165 curr_srec
->line
= data
;
4167 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4170 case DST__K_SRC_SETREC_L
:
4171 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4172 curr_srec
->srec
= data
;
4173 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4175 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4178 case DST__K_SRC_SETREC_W
:
4179 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4180 curr_srec
->srec
= data
;
4181 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4183 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4186 case DST__K_SRC_FORMFEED
:
4188 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4192 (*_bfd_error_handler
) (_("unknown source command %d"),
4198 src_ptr
+= cmd_length
;
4202 case DST__K_LINE_NUM
:
4203 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4205 vms_debug2 ((3, "line info\n"));
4207 while (pcl_ptr
< ptr
+ rec_length
)
4209 /* The command byte is signed so we must sign-extend it. */
4210 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4214 case DST__K_DELTA_PC_W
:
4215 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4219 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4222 case DST__K_DELTA_PC_L
:
4223 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4227 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4230 case DST__K_INCR_LINUM
:
4231 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4232 curr_linenum
+= data
;
4234 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4237 case DST__K_INCR_LINUM_W
:
4238 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4239 curr_linenum
+= data
;
4241 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4244 case DST__K_INCR_LINUM_L
:
4245 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4246 curr_linenum
+= data
;
4248 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4251 case DST__K_SET_LINUM_INCR
:
4252 (*_bfd_error_handler
)
4253 (_("DST__K_SET_LINUM_INCR not implemented"));
4257 case DST__K_SET_LINUM_INCR_W
:
4258 (*_bfd_error_handler
)
4259 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4263 case DST__K_RESET_LINUM_INCR
:
4264 (*_bfd_error_handler
)
4265 (_("DST__K_RESET_LINUM_INCR not implemented"));
4269 case DST__K_BEG_STMT_MODE
:
4270 (*_bfd_error_handler
)
4271 (_("DST__K_BEG_STMT_MODE not implemented"));
4275 case DST__K_END_STMT_MODE
:
4276 (*_bfd_error_handler
)
4277 (_("DST__K_END_STMT_MODE not implemented"));
4281 case DST__K_SET_LINUM_B
:
4282 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4283 curr_linenum
= data
;
4285 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4288 case DST__K_SET_LINUM
:
4289 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4290 curr_linenum
= data
;
4292 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4295 case DST__K_SET_LINUM_L
:
4296 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4297 curr_linenum
= data
;
4299 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4303 (*_bfd_error_handler
)
4304 (_("DST__K_SET_PC not implemented"));
4308 case DST__K_SET_PC_W
:
4309 (*_bfd_error_handler
)
4310 (_("DST__K_SET_PC_W not implemented"));
4314 case DST__K_SET_PC_L
:
4315 (*_bfd_error_handler
)
4316 (_("DST__K_SET_PC_L not implemented"));
4320 case DST__K_SET_STMTNUM
:
4321 (*_bfd_error_handler
)
4322 (_("DST__K_SET_STMTNUM not implemented"));
4327 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4330 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4334 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4337 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4341 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4344 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4347 case DST__K_SET_ABS_PC
:
4348 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4351 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4360 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4361 (unsigned long)curr_pc
, curr_linenum
));
4365 (*_bfd_error_handler
) (_("unknown line command %d"),
4372 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4374 || cmd
== DST__K_DELTA_PC_L
4375 || cmd
== DST__K_DELTA_PC_W
)
4377 line
= (struct lineinfo
*)
4378 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4379 line
->address
= curr_pc
;
4380 line
->line
= curr_linenum
;
4382 curr_line
->next
= line
;
4385 prev_linum
= curr_linenum
;
4387 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4388 (unsigned long)curr_pc
, curr_linenum
));
4391 pcl_ptr
+= cmd_length
;
4395 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4396 vms_debug2 ((3, "undocumented type 0x17\n"));
4400 vms_debug2 ((3, "ignoring record\n"));
4408 /* Finalize tables with EOL marker. */
4409 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4410 srec
->line
= (unsigned int) -1;
4411 srec
->srec
= (unsigned int) -1;
4412 curr_srec
->next
= srec
;
4414 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4415 line
->line
= (unsigned int) -1;
4416 line
->address
= (bfd_vma
) -1;
4417 curr_line
->next
= line
;
4419 /* Advertise that this module has been parsed. This is needed
4420 because parsing can be either performed at module creation
4421 or deferred until debug info is consumed. */
4422 SET_MODULE_PARSED (module
);
4425 /* Build the list of modules for the specified BFD. */
4427 static struct module
*
4428 build_module_list (bfd
*abfd
)
4430 struct module
*module
, *list
= NULL
;
4433 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4435 /* We have a DMT section so this must be an image. Parse the
4436 section and build the list of modules. This is sufficient
4437 since we can compute the start address and the end address
4438 of every module from the section contents. */
4439 bfd_size_type size
= bfd_get_section_size (dmt
);
4440 unsigned char *ptr
, *end
;
4442 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4446 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4449 vms_debug2 ((2, "DMT\n"));
4455 /* Each header declares a module with its start offset and size
4456 of debug info in the DST section, as well as the count of
4457 program sections (i.e. address spans) it contains. */
4458 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4459 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4460 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4461 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4463 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4464 modbeg
, msize
, count
));
4466 /* We create a 'module' structure for each program section since
4467 we only support contiguous addresses in a 'module' structure.
4468 As a consequence, the actual debug info in the DST section is
4469 shared and can be parsed multiple times; that doesn't seem to
4470 cause problems in practice. */
4473 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4474 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4475 module
= new_module (abfd
);
4476 module
->modbeg
= modbeg
;
4477 module
->size
= msize
;
4478 module
->low
= start
;
4479 module
->high
= start
+ length
;
4480 module
->next
= list
;
4482 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4484 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4491 /* We don't have a DMT section so this must be an object. Parse
4492 the module right now in order to compute its start address and
4494 void *dst
= PRIV (dst_section
)->contents
;
4499 module
= new_module (abfd
);
4500 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4507 /* Calculate and return the name of the source file and the line nearest
4508 to the wanted location in the specified module. */
4511 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4512 const char **file
, const char **func
,
4515 struct funcinfo
*funcinfo
;
4516 struct lineinfo
*lineinfo
;
4517 struct srecinfo
*srecinfo
;
4518 bfd_boolean ret
= FALSE
;
4520 /* Parse this module if that was not done at module creation. */
4521 if (! IS_MODULE_PARSED (module
))
4523 unsigned int size
= module
->size
;
4524 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4525 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4527 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4528 || bfd_bread (buffer
, size
, abfd
) != size
)
4530 bfd_set_error (bfd_error_no_debug_section
);
4534 parse_module (abfd
, module
, buffer
, size
);
4538 /* Find out the function (if any) that contains the address. */
4539 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4540 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4542 *func
= funcinfo
->name
;
4547 /* Find out the source file and the line nearest to the address. */
4548 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4549 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4551 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4552 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4554 if (srecinfo
->sfile
> 0)
4556 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4557 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4561 *file
= module
->name
;
4562 *line
= lineinfo
->line
;
4573 /* Provided a BFD, a section and an offset into the section, calculate and
4574 return the name of the source file and the line nearest to the wanted
4578 _bfd_vms_find_nearest_dst_line (bfd
*abfd
, asection
*section
,
4579 asymbol
**symbols ATTRIBUTE_UNUSED
,
4580 bfd_vma offset
, const char **file
,
4581 const char **func
, unsigned int *line
)
4583 struct module
*module
;
4585 /* What address are we looking for? */
4586 bfd_vma addr
= section
->vma
+ offset
;
4592 /* We can't do anything if there is no DST (debug symbol table). */
4593 if (PRIV (dst_section
) == NULL
)
4596 /* Create the module list - if not already done. */
4597 if (PRIV (modules
) == NULL
)
4599 PRIV (modules
) = build_module_list (abfd
);
4600 if (PRIV (modules
) == NULL
)
4604 for (module
= PRIV (modules
); module
; module
= module
->next
)
4605 if (addr
>= module
->low
&& addr
<= module
->high
)
4606 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4611 /* Likewise but with a discriminator. */
4614 _bfd_vms_find_nearest_line_discriminator (bfd
*abfd
,
4618 const char **filename_ptr
,
4619 const char **functionname_ptr
,
4620 unsigned int *line_ptr
,
4621 unsigned int *discriminator
)
4625 return _bfd_vms_find_nearest_dst_line (abfd
, section
, symbols
, offset
,
4626 filename_ptr
, functionname_ptr
,
4631 /* Canonicalizations. */
4632 /* Set name, value, section and flags of SYM from E. */
4635 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4644 flags
= BSF_NO_FLAGS
;
4650 if (e
->flags
& EGSY__V_WEAK
)
4653 if (e
->flags
& EGSY__V_DEF
)
4655 /* Symbol definition. */
4656 flags
|= BSF_GLOBAL
;
4657 if (e
->flags
& EGSY__V_NORM
)
4658 flags
|= BSF_FUNCTION
;
4664 /* Symbol reference. */
4665 sec
= bfd_und_section_ptr
;
4670 /* A universal symbol is by definition global... */
4671 flags
|= BSF_GLOBAL
;
4673 /* ...and dynamic in shared libraries. */
4674 if (abfd
->flags
& DYNAMIC
)
4675 flags
|= BSF_DYNAMIC
;
4677 if (e
->flags
& EGSY__V_WEAK
)
4680 if (!(e
->flags
& EGSY__V_DEF
))
4683 if (e
->flags
& EGSY__V_NORM
)
4684 flags
|= BSF_FUNCTION
;
4687 /* sec = e->section; */
4688 sec
= bfd_abs_section_ptr
;
4703 /* Return the number of bytes required to store a vector of pointers
4704 to asymbols for all the symbols in the BFD abfd, including a
4705 terminal NULL pointer. If there are no symbols in the BFD,
4706 then return 0. If an error occurs, return -1. */
4709 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4711 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4712 abfd
, PRIV (gsd_sym_count
)));
4714 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4717 /* Read the symbols from the BFD abfd, and fills in the vector
4718 location with pointers to the symbols and a trailing NULL.
4720 Return number of symbols read. */
4723 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4727 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4729 if (PRIV (csymbols
) == NULL
)
4731 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4732 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4734 /* Traverse table and fill symbols vector. */
4735 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4737 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4740 sym
= bfd_make_empty_symbol (abfd
);
4741 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4743 bfd_release (abfd
, PRIV (csymbols
));
4744 PRIV (csymbols
) = NULL
;
4748 PRIV (csymbols
)[i
] = sym
;
4752 if (symbols
!= NULL
)
4754 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4755 symbols
[i
] = PRIV (csymbols
)[i
];
4759 return PRIV (gsd_sym_count
);
4762 /* Read and convert relocations from ETIR. We do it once for all sections. */
4765 alpha_vms_slurp_relocs (bfd
*abfd
)
4769 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4771 /* We slurp relocs only once, for all sections. */
4772 if (PRIV (reloc_done
))
4774 PRIV (reloc_done
) = TRUE
;
4776 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4779 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4784 unsigned char *begin
;
4787 bfd_reloc_code_real_type reloc_code
;
4793 bfd_vma cur_address
;
4795 unsigned char *cur_sym
= NULL
;
4797 bfd_vma cur_addend
= 0;
4799 /* Skip non-ETIR records. */
4800 type
= _bfd_vms_get_object_record (abfd
);
4801 if (type
== EOBJ__C_EEOM
)
4803 if (type
!= EOBJ__C_ETIR
)
4806 begin
= PRIV (recrd
.rec
) + 4;
4807 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4809 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4813 cmd
= bfd_getl16 (ptr
);
4814 length
= bfd_getl16 (ptr
+ 2);
4816 cur_address
= vaddr
;
4818 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4819 _bfd_vms_etir_name (cmd
)));
4823 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4824 /* ALPHA_R_REFQUAD und_section, step 1 */
4829 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4830 cur_psidx
= bfd_getl32 (ptr
+ 4);
4831 cur_addend
= bfd_getl64 (ptr
+ 8);
4835 case ETIR__C_CTL_SETRB
:
4836 if (prev_cmd
!= ETIR__C_STA_PQ
)
4838 (*_bfd_error_handler
)
4839 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
4840 _bfd_vms_etir_name (cmd
));
4843 cur_psect
= cur_psidx
;
4849 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
4850 /* ALPHA_R_REFLONG und_section, step 2 */
4853 if (prev_cmd
!= ETIR__C_STA_GBL
)
4855 (*_bfd_error_handler
)
4856 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4857 _bfd_vms_etir_name (ETIR__C_STA_LW
));
4861 cur_addend
= bfd_getl32 (ptr
+ 4);
4865 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
4866 /* ALPHA_R_REFQUAD und_section, step 2 */
4867 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
4869 (*_bfd_error_handler
)
4870 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4871 _bfd_vms_etir_name (ETIR__C_STA_QW
));
4874 cur_addend
= bfd_getl64 (ptr
+ 4);
4878 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
4879 /* ALPHA_R_REFLONG abs_section, step 2 */
4880 /* ALPHA_R_REFLONG others, step 2 */
4881 if (prev_cmd
!= ETIR__C_OPR_ADD
4882 && prev_cmd
!= ETIR__C_STA_LW
4883 && prev_cmd
!= ETIR__C_STA_PQ
)
4885 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4886 _bfd_vms_etir_name (prev_cmd
),
4887 _bfd_vms_etir_name (ETIR__C_STO_LW
));
4890 reloc_code
= BFD_RELOC_32
;
4893 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
4894 /* ALPHA_R_REFQUAD abs_section, step 2 */
4895 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
4897 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4898 _bfd_vms_etir_name (prev_cmd
),
4899 _bfd_vms_etir_name (ETIR__C_STO_QW
));
4902 reloc_code
= BFD_RELOC_64
;
4905 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
4906 if (prev_cmd
!= ETIR__C_STA_PQ
)
4908 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4909 _bfd_vms_etir_name (prev_cmd
),
4910 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
4913 reloc_code
= BFD_RELOC_64
;
4916 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
4917 /* ALPHA_R_REFQUAD und_section, step 3 */
4918 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
4920 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4921 _bfd_vms_etir_name (prev_cmd
),
4922 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
4925 prev_cmd
= ETIR__C_OPR_ADD
;
4928 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
4929 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
4933 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
4934 reloc_code
= BFD_RELOC_64
;
4938 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
4939 reloc_code
= BFD_RELOC_32
;
4943 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
4944 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
4948 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
4949 reloc_code
= BFD_RELOC_ALPHA_NOP
;
4952 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
4953 reloc_code
= BFD_RELOC_ALPHA_BSR
;
4956 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
4957 reloc_code
= BFD_RELOC_ALPHA_LDA
;
4960 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
4961 reloc_code
= BFD_RELOC_ALPHA_BOH
;
4965 cur_sym
= ptr
+ 4 + 32;
4966 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
4967 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
4970 case ETIR__C_STO_IMM
:
4971 vaddr
+= bfd_getl32 (ptr
+ 4);
4975 (*_bfd_error_handler
) (_("Unknown reloc %s"),
4976 _bfd_vms_etir_name (cmd
));
4982 struct vms_section_data_struct
*vms_sec
;
4985 /* Get section to which the relocation applies. */
4986 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
4988 (*_bfd_error_handler
) (_("Invalid section index in ETIR"));
4992 sec
= PRIV (sections
)[cur_psect
];
4993 if (sec
== bfd_abs_section_ptr
)
4995 (*_bfd_error_handler
) (_("Relocation for non-REL psect"));
4999 vms_sec
= vms_section_data (sec
);
5001 /* Allocate a reloc entry. */
5002 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
5004 if (vms_sec
->reloc_max
== 0)
5006 vms_sec
->reloc_max
= 64;
5007 sec
->relocation
= bfd_zmalloc
5008 (vms_sec
->reloc_max
* sizeof (arelent
));
5012 vms_sec
->reloc_max
*= 2;
5013 sec
->relocation
= bfd_realloc
5014 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
5017 reloc
= &sec
->relocation
[sec
->reloc_count
];
5020 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
5022 if (cur_sym
!= NULL
)
5025 unsigned int symlen
= *cur_sym
;
5028 /* Linear search. */
5033 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
5034 if (PRIV (syms
)[j
]->namelen
== symlen
5035 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
5037 sym
= &PRIV (csymbols
)[j
];
5042 (*_bfd_error_handler
) (_("Unknown symbol in command %s"),
5043 _bfd_vms_etir_name (cmd
));
5044 reloc
->sym_ptr_ptr
= NULL
;
5047 reloc
->sym_ptr_ptr
= sym
;
5049 else if (cur_psidx
>= 0)
5050 reloc
->sym_ptr_ptr
=
5051 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5053 reloc
->sym_ptr_ptr
= NULL
;
5055 reloc
->address
= cur_address
;
5056 reloc
->addend
= cur_addend
;
5058 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5067 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5072 /* Return the number of bytes required to store the relocation
5073 information associated with the given section. */
5076 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5078 alpha_vms_slurp_relocs (abfd
);
5080 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5083 /* Convert relocations from VMS (external) form into BFD internal
5084 form. Return the number of relocations. */
5087 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5088 asymbol
**symbols ATTRIBUTE_UNUSED
)
5093 if (!alpha_vms_slurp_relocs (abfd
))
5096 count
= section
->reloc_count
;
5097 tblptr
= section
->relocation
;
5100 *relptr
++ = tblptr
++;
5102 *relptr
= (arelent
*) NULL
;
5103 return section
->reloc_count
;
5106 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5108 /* How to process the various reloc types. */
5110 static bfd_reloc_status_type
5111 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5112 arelent
*reloc ATTRIBUTE_UNUSED
,
5113 asymbol
*sym ATTRIBUTE_UNUSED
,
5114 void * data ATTRIBUTE_UNUSED
,
5115 asection
*sec ATTRIBUTE_UNUSED
,
5116 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5117 char **error_message ATTRIBUTE_UNUSED
)
5120 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5121 vms_debug (2, "In section %s, symbol %s\n",
5122 sec
->name
, sym
->name
);
5123 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5124 reloc
->sym_ptr_ptr
[0]->name
,
5125 (unsigned long)reloc
->address
,
5126 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5127 vms_debug (2, "data at %p\n", data
);
5128 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5131 return bfd_reloc_ok
;
5134 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5135 from smaller values. Start with zero, widen, *then* decrement. */
5136 #define MINUS_ONE (((bfd_vma)0) - 1)
5138 static reloc_howto_type alpha_howto_table
[] =
5140 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5141 0, /* Rightshift. */
5142 0, /* Size (0 = byte, 1 = short, 2 = long). */
5144 TRUE
, /* PC relative. */
5146 complain_overflow_dont
,/* Complain_on_overflow. */
5147 reloc_nil
, /* Special_function. */
5148 "IGNORE", /* Name. */
5149 TRUE
, /* Partial_inplace. */
5150 0, /* Source mask */
5152 TRUE
), /* PC rel offset. */
5154 /* A 64 bit reference to a symbol. */
5155 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5156 0, /* Rightshift. */
5157 4, /* Size (0 = byte, 1 = short, 2 = long). */
5159 FALSE
, /* PC relative. */
5161 complain_overflow_bitfield
, /* Complain_on_overflow. */
5162 reloc_nil
, /* Special_function. */
5163 "REFQUAD", /* Name. */
5164 TRUE
, /* Partial_inplace. */
5165 MINUS_ONE
, /* Source mask. */
5166 MINUS_ONE
, /* Dest mask. */
5167 FALSE
), /* PC rel offset. */
5169 /* A 21 bit branch. The native assembler generates these for
5170 branches within the text segment, and also fills in the PC
5171 relative offset in the instruction. */
5172 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5173 2, /* Rightshift. */
5174 2, /* Size (0 = byte, 1 = short, 2 = long). */
5176 TRUE
, /* PC relative. */
5178 complain_overflow_signed
, /* Complain_on_overflow. */
5179 reloc_nil
, /* Special_function. */
5180 "BRADDR", /* Name. */
5181 TRUE
, /* Partial_inplace. */
5182 0x1fffff, /* Source mask. */
5183 0x1fffff, /* Dest mask. */
5184 FALSE
), /* PC rel offset. */
5186 /* A hint for a jump to a register. */
5187 HOWTO (ALPHA_R_HINT
, /* Type. */
5188 2, /* Rightshift. */
5189 1, /* Size (0 = byte, 1 = short, 2 = long). */
5191 TRUE
, /* PC relative. */
5193 complain_overflow_dont
,/* Complain_on_overflow. */
5194 reloc_nil
, /* Special_function. */
5196 TRUE
, /* Partial_inplace. */
5197 0x3fff, /* Source mask. */
5198 0x3fff, /* Dest mask. */
5199 FALSE
), /* PC rel offset. */
5201 /* 16 bit PC relative offset. */
5202 HOWTO (ALPHA_R_SREL16
, /* Type. */
5203 0, /* Rightshift. */
5204 1, /* Size (0 = byte, 1 = short, 2 = long). */
5206 TRUE
, /* PC relative. */
5208 complain_overflow_signed
, /* Complain_on_overflow. */
5209 reloc_nil
, /* Special_function. */
5210 "SREL16", /* Name. */
5211 TRUE
, /* Partial_inplace. */
5212 0xffff, /* Source mask. */
5213 0xffff, /* Dest mask. */
5214 FALSE
), /* PC rel offset. */
5216 /* 32 bit PC relative offset. */
5217 HOWTO (ALPHA_R_SREL32
, /* Type. */
5218 0, /* Rightshift. */
5219 2, /* Size (0 = byte, 1 = short, 2 = long). */
5221 TRUE
, /* PC relative. */
5223 complain_overflow_signed
, /* Complain_on_overflow. */
5224 reloc_nil
, /* Special_function. */
5225 "SREL32", /* Name. */
5226 TRUE
, /* Partial_inplace. */
5227 0xffffffff, /* Source mask. */
5228 0xffffffff, /* Dest mask. */
5229 FALSE
), /* PC rel offset. */
5231 /* A 64 bit PC relative offset. */
5232 HOWTO (ALPHA_R_SREL64
, /* Type. */
5233 0, /* Rightshift. */
5234 4, /* Size (0 = byte, 1 = short, 2 = long). */
5236 TRUE
, /* PC relative. */
5238 complain_overflow_signed
, /* Complain_on_overflow. */
5239 reloc_nil
, /* Special_function. */
5240 "SREL64", /* Name. */
5241 TRUE
, /* Partial_inplace. */
5242 MINUS_ONE
, /* Source mask. */
5243 MINUS_ONE
, /* Dest mask. */
5244 FALSE
), /* PC rel offset. */
5246 /* Push a value on the reloc evaluation stack. */
5247 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5248 0, /* Rightshift. */
5249 0, /* Size (0 = byte, 1 = short, 2 = long). */
5251 FALSE
, /* PC relative. */
5253 complain_overflow_dont
,/* Complain_on_overflow. */
5254 reloc_nil
, /* Special_function. */
5255 "OP_PUSH", /* Name. */
5256 FALSE
, /* Partial_inplace. */
5257 0, /* Source mask. */
5259 FALSE
), /* PC rel offset. */
5261 /* Store the value from the stack at the given address. Store it in
5262 a bitfield of size r_size starting at bit position r_offset. */
5263 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5264 0, /* Rightshift. */
5265 4, /* Size (0 = byte, 1 = short, 2 = long). */
5267 FALSE
, /* PC relative. */
5269 complain_overflow_dont
,/* Complain_on_overflow. */
5270 reloc_nil
, /* Special_function. */
5271 "OP_STORE", /* Name. */
5272 FALSE
, /* Partial_inplace. */
5273 0, /* Source mask. */
5274 MINUS_ONE
, /* Dest mask. */
5275 FALSE
), /* PC rel offset. */
5277 /* Subtract the reloc address from the value on the top of the
5278 relocation stack. */
5279 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5280 0, /* Rightshift. */
5281 0, /* Size (0 = byte, 1 = short, 2 = long). */
5283 FALSE
, /* PC relative. */
5285 complain_overflow_dont
,/* Complain_on_overflow. */
5286 reloc_nil
, /* Special_function. */
5287 "OP_PSUB", /* Name. */
5288 FALSE
, /* Partial_inplace. */
5289 0, /* Source mask. */
5291 FALSE
), /* PC rel offset. */
5293 /* Shift the value on the top of the relocation stack right by the
5295 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5296 0, /* Rightshift. */
5297 0, /* Size (0 = byte, 1 = short, 2 = long). */
5299 FALSE
, /* PC relative. */
5301 complain_overflow_dont
,/* Complain_on_overflow. */
5302 reloc_nil
, /* Special_function. */
5303 "OP_PRSHIFT", /* Name. */
5304 FALSE
, /* Partial_inplace. */
5305 0, /* Source mask. */
5307 FALSE
), /* PC rel offset. */
5309 /* Hack. Linkage is done by linker. */
5310 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5311 0, /* Rightshift. */
5312 8, /* Size (0 = byte, 1 = short, 2 = long). */
5314 FALSE
, /* PC relative. */
5316 complain_overflow_dont
,/* Complain_on_overflow. */
5317 reloc_nil
, /* Special_function. */
5318 "LINKAGE", /* Name. */
5319 FALSE
, /* Partial_inplace. */
5320 0, /* Source mask. */
5322 FALSE
), /* PC rel offset. */
5324 /* A 32 bit reference to a symbol. */
5325 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5326 0, /* Rightshift. */
5327 2, /* Size (0 = byte, 1 = short, 2 = long). */
5329 FALSE
, /* PC relative. */
5331 complain_overflow_bitfield
, /* Complain_on_overflow. */
5332 reloc_nil
, /* Special_function. */
5333 "REFLONG", /* Name. */
5334 TRUE
, /* Partial_inplace. */
5335 0xffffffff, /* Source mask. */
5336 0xffffffff, /* Dest mask. */
5337 FALSE
), /* PC rel offset. */
5339 /* A 64 bit reference to a procedure, written as 32 bit value. */
5340 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5341 0, /* Rightshift. */
5342 4, /* Size (0 = byte, 1 = short, 2 = long). */
5344 FALSE
, /* PC relative. */
5346 complain_overflow_signed
,/* Complain_on_overflow. */
5347 reloc_nil
, /* Special_function. */
5348 "CODEADDR", /* Name. */
5349 FALSE
, /* Partial_inplace. */
5350 0xffffffff, /* Source mask. */
5351 0xffffffff, /* Dest mask. */
5352 FALSE
), /* PC rel offset. */
5354 HOWTO (ALPHA_R_NOP
, /* Type. */
5355 0, /* Rightshift. */
5356 3, /* Size (0 = byte, 1 = short, 2 = long). */
5358 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5359 because the calculations for the 3 relocations are the same.
5360 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5361 TRUE
, /* PC relative. */
5363 complain_overflow_dont
,/* Complain_on_overflow. */
5364 reloc_nil
, /* Special_function. */
5366 FALSE
, /* Partial_inplace. */
5367 0xffffffff, /* Source mask. */
5368 0xffffffff, /* Dest mask. */
5369 FALSE
), /* PC rel offset. */
5371 HOWTO (ALPHA_R_BSR
, /* Type. */
5372 0, /* Rightshift. */
5373 3, /* Size (0 = byte, 1 = short, 2 = long). */
5375 TRUE
, /* PC relative. */
5377 complain_overflow_dont
,/* Complain_on_overflow. */
5378 reloc_nil
, /* Special_function. */
5380 FALSE
, /* Partial_inplace. */
5381 0xffffffff, /* Source mask. */
5382 0xffffffff, /* Dest mask. */
5383 FALSE
), /* PC rel offset. */
5385 HOWTO (ALPHA_R_LDA
, /* Type. */
5386 0, /* Rightshift. */
5387 3, /* Size (0 = byte, 1 = short, 2 = long). */
5389 FALSE
, /* PC relative. */
5391 complain_overflow_dont
,/* Complain_on_overflow. */
5392 reloc_nil
, /* Special_function. */
5394 FALSE
, /* Partial_inplace. */
5395 0xffffffff, /* Source mask. */
5396 0xffffffff, /* Dest mask. */
5397 FALSE
), /* PC rel offset. */
5399 HOWTO (ALPHA_R_BOH
, /* Type. */
5400 0, /* Rightshift. */
5401 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5403 TRUE
, /* PC relative. */
5405 complain_overflow_dont
,/* Complain_on_overflow. */
5406 reloc_nil
, /* Special_function. */
5408 FALSE
, /* Partial_inplace. */
5409 0xffffffff, /* Source mask. */
5410 0xffffffff, /* Dest mask. */
5411 FALSE
), /* PC rel offset. */
5414 /* Return a pointer to a howto structure which, when invoked, will perform
5415 the relocation code on data from the architecture noted. */
5417 static const struct reloc_howto_struct
*
5418 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5419 bfd_reloc_code_real_type code
)
5423 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5427 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5428 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5429 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5430 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5431 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5432 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5433 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5434 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5435 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5436 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5437 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5438 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5439 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5440 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5441 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5443 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
5446 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5447 return & alpha_howto_table
[alpha_type
];
5450 static reloc_howto_type
*
5451 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5457 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5459 if (alpha_howto_table
[i
].name
!= NULL
5460 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5461 return &alpha_howto_table
[i
];
5467 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5468 long symcount ATTRIBUTE_UNUSED
,
5469 asymbol
**usyms ATTRIBUTE_UNUSED
,
5470 long dynsymcount ATTRIBUTE_UNUSED
,
5471 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5478 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5483 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5485 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5496 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5503 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5505 value
= e
->code_value
;
5506 sec
= e
->code_section
;
5517 sname
= bfd_alloc (abfd
, l
+ 5);
5520 memcpy (sname
, name
, l
);
5521 memcpy (sname
+ l
, "..en", 5);
5528 sym
->udata
.p
= NULL
;
5537 vms_time_to_str (unsigned char *buf
)
5539 time_t t
= vms_rawtime_to_time_t (buf
);
5540 char *res
= ctime (&t
);
5543 res
= "*invalid time*";
5550 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5552 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5553 unsigned int subtype
;
5555 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5557 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5563 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5566 fprintf (file
, _("Module header\n"));
5567 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5568 fprintf (file
, _(" max record size: %u\n"),
5569 (unsigned)bfd_getl32 (mhd
->recsiz
));
5570 name
= (char *)(mhd
+ 1);
5571 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5572 name
+= name
[0] + 1;
5573 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5574 name
+= name
[0] + 1;
5575 fprintf (file
, _(" compile date : %.17s\n"), name
);
5580 fprintf (file
, _("Language Processor Name\n"));
5581 fprintf (file
, _(" language name: %.*s\n"),
5582 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5583 (char *)rec
+ sizeof (struct vms_emh_common
));
5588 fprintf (file
, _("Source Files Header\n"));
5589 fprintf (file
, _(" file: %.*s\n"),
5590 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5591 (char *)rec
+ sizeof (struct vms_emh_common
));
5596 fprintf (file
, _("Title Text Header\n"));
5597 fprintf (file
, _(" title: %.*s\n"),
5598 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5599 (char *)rec
+ sizeof (struct vms_emh_common
));
5604 fprintf (file
, _("Copyright Header\n"));
5605 fprintf (file
, _(" copyright: %.*s\n"),
5606 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5607 (char *)rec
+ sizeof (struct vms_emh_common
));
5611 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5617 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5619 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5621 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5622 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5623 (unsigned)bfd_getl32 (eeom
->total_lps
));
5624 fprintf (file
, _(" completion code: %u\n"),
5625 (unsigned)bfd_getl16 (eeom
->comcod
));
5628 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5629 fprintf (file
, _(" transfer addr psect: %u\n"),
5630 (unsigned)bfd_getl32 (eeom
->psindx
));
5631 fprintf (file
, _(" transfer address : 0x%08x\n"),
5632 (unsigned)bfd_getl32 (eeom
->tfradr
));
5637 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5639 if (flags
& EGSY__V_WEAK
)
5640 fputs (_(" WEAK"), file
);
5641 if (flags
& EGSY__V_DEF
)
5642 fputs (_(" DEF"), file
);
5643 if (flags
& EGSY__V_UNI
)
5644 fputs (_(" UNI"), file
);
5645 if (flags
& EGSY__V_REL
)
5646 fputs (_(" REL"), file
);
5647 if (flags
& EGSY__V_COMM
)
5648 fputs (_(" COMM"), file
);
5649 if (flags
& EGSY__V_VECEP
)
5650 fputs (_(" VECEP"), file
);
5651 if (flags
& EGSY__V_NORM
)
5652 fputs (_(" NORM"), file
);
5653 if (flags
& EGSY__V_QUAD_VAL
)
5654 fputs (_(" QVAL"), file
);
5658 evax_bfd_print_egsd_flags (FILE *file
, unsigned int flags
)
5660 if (flags
& EGPS__V_PIC
)
5661 fputs (_(" PIC"), file
);
5662 if (flags
& EGPS__V_LIB
)
5663 fputs (_(" LIB"), file
);
5664 if (flags
& EGPS__V_OVR
)
5665 fputs (_(" OVR"), file
);
5666 if (flags
& EGPS__V_REL
)
5667 fputs (_(" REL"), file
);
5668 if (flags
& EGPS__V_GBL
)
5669 fputs (_(" GBL"), file
);
5670 if (flags
& EGPS__V_SHR
)
5671 fputs (_(" SHR"), file
);
5672 if (flags
& EGPS__V_EXE
)
5673 fputs (_(" EXE"), file
);
5674 if (flags
& EGPS__V_RD
)
5675 fputs (_(" RD"), file
);
5676 if (flags
& EGPS__V_WRT
)
5677 fputs (_(" WRT"), file
);
5678 if (flags
& EGPS__V_VEC
)
5679 fputs (_(" VEC"), file
);
5680 if (flags
& EGPS__V_NOMOD
)
5681 fputs (_(" NOMOD"), file
);
5682 if (flags
& EGPS__V_COM
)
5683 fputs (_(" COM"), file
);
5684 if (flags
& EGPS__V_ALLOC_64BIT
)
5685 fputs (_(" 64B"), file
);
5689 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5691 unsigned int off
= sizeof (struct vms_egsd
);
5694 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5697 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5699 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5703 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5704 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5706 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5714 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5715 unsigned int flags
= bfd_getl16 (egps
->flags
);
5718 fprintf (file
, _("PSC - Program section definition\n"));
5719 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5720 fprintf (file
, _(" flags : 0x%04x"), flags
);
5721 evax_bfd_print_egsd_flags (file
, flags
);
5723 l
= bfd_getl32 (egps
->alloc
);
5724 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5725 fprintf (file
, _(" name : %.*s\n"),
5726 egps
->namlng
, egps
->name
);
5731 struct vms_esgps
*esgps
= (struct vms_esgps
*)e
;
5732 unsigned int flags
= bfd_getl16 (esgps
->flags
);
5735 fprintf (file
, _("SPSC - Shared Image Program section def\n"));
5736 fprintf (file
, _(" alignment : 2**%u\n"), esgps
->align
);
5737 fprintf (file
, _(" flags : 0x%04x"), flags
);
5738 evax_bfd_print_egsd_flags (file
, flags
);
5740 l
= bfd_getl32 (esgps
->alloc
);
5741 fprintf (file
, _(" alloc (len) : %u (0x%08x)\n"), l
, l
);
5742 fprintf (file
, _(" image offset : 0x%08x\n"),
5743 (unsigned int)bfd_getl32 (esgps
->base
));
5744 fprintf (file
, _(" symvec offset : 0x%08x\n"),
5745 (unsigned int)bfd_getl32 (esgps
->value
));
5746 fprintf (file
, _(" name : %.*s\n"),
5747 esgps
->namlng
, esgps
->name
);
5752 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5753 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5755 if (flags
& EGSY__V_DEF
)
5757 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5759 fprintf (file
, _("SYM - Global symbol definition\n"));
5760 fprintf (file
, _(" flags: 0x%04x"), flags
);
5761 exav_bfd_print_egsy_flags (flags
, file
);
5763 fprintf (file
, _(" psect offset: 0x%08x\n"),
5764 (unsigned)bfd_getl32 (esdf
->value
));
5765 if (flags
& EGSY__V_NORM
)
5767 fprintf (file
, _(" code address: 0x%08x\n"),
5768 (unsigned)bfd_getl32 (esdf
->code_address
));
5769 fprintf (file
, _(" psect index for entry point : %u\n"),
5770 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5772 fprintf (file
, _(" psect index : %u\n"),
5773 (unsigned)bfd_getl32 (esdf
->psindx
));
5774 fprintf (file
, _(" name : %.*s\n"),
5775 esdf
->namlng
, esdf
->name
);
5779 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5781 fprintf (file
, _("SYM - Global symbol reference\n"));
5782 fprintf (file
, _(" name : %.*s\n"),
5783 esrf
->namlng
, esrf
->name
);
5789 struct vms_eidc
*eidc
= (struct vms_eidc
*)e
;
5790 unsigned int flags
= bfd_getl32 (eidc
->flags
);
5793 fprintf (file
, _("IDC - Ident Consistency check\n"));
5794 fprintf (file
, _(" flags : 0x%08x"), flags
);
5795 if (flags
& EIDC__V_BINIDENT
)
5796 fputs (" BINDENT", file
);
5798 fprintf (file
, _(" id match : %x\n"),
5799 (flags
>> EIDC__V_IDMATCH_SH
) & EIDC__V_IDMATCH_MASK
);
5800 fprintf (file
, _(" error severity: %x\n"),
5801 (flags
>> EIDC__V_ERRSEV_SH
) & EIDC__V_ERRSEV_MASK
);
5803 fprintf (file
, _(" entity name : %.*s\n"), p
[0], p
+ 1);
5805 fprintf (file
, _(" object name : %.*s\n"), p
[0], p
+ 1);
5807 if (flags
& EIDC__V_BINIDENT
)
5808 fprintf (file
, _(" binary ident : 0x%08x\n"),
5809 (unsigned)bfd_getl32 (p
+ 1));
5811 fprintf (file
, _(" ascii ident : %.*s\n"), p
[0], p
+ 1);
5816 struct vms_egst
*egst
= (struct vms_egst
*)e
;
5817 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
5819 fprintf (file
, _("SYMG - Universal symbol definition\n"));
5820 fprintf (file
, _(" flags: 0x%04x"), flags
);
5821 exav_bfd_print_egsy_flags (flags
, file
);
5823 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
5824 (unsigned)bfd_getl32 (egst
->value
));
5825 fprintf (file
, _(" entry point: 0x%08x\n"),
5826 (unsigned)bfd_getl32 (egst
->lp_1
));
5827 fprintf (file
, _(" proc descr : 0x%08x\n"),
5828 (unsigned)bfd_getl32 (egst
->lp_2
));
5829 fprintf (file
, _(" psect index: %u\n"),
5830 (unsigned)bfd_getl32 (egst
->psindx
));
5831 fprintf (file
, _(" name : %.*s\n"),
5832 egst
->namlng
, egst
->name
);
5837 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
5838 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
5840 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
5841 fprintf (file
, _(" flags: 0x%04x"), flags
);
5842 exav_bfd_print_egsy_flags (flags
, file
);
5844 fprintf (file
, _(" vector : 0x%08x\n"),
5845 (unsigned)bfd_getl32 (esdfv
->vector
));
5846 fprintf (file
, _(" psect offset: %u\n"),
5847 (unsigned)bfd_getl32 (esdfv
->value
));
5848 fprintf (file
, _(" psect index : %u\n"),
5849 (unsigned)bfd_getl32 (esdfv
->psindx
));
5850 fprintf (file
, _(" name : %.*s\n"),
5851 esdfv
->namlng
, esdfv
->name
);
5856 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
5857 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
5859 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
5860 fprintf (file
, _(" flags: 0x%04x"), flags
);
5861 exav_bfd_print_egsy_flags (flags
, file
);
5863 fprintf (file
, _(" version mask: 0x%08x\n"),
5864 (unsigned)bfd_getl32 (esdfm
->version_mask
));
5865 fprintf (file
, _(" psect offset: %u\n"),
5866 (unsigned)bfd_getl32 (esdfm
->value
));
5867 fprintf (file
, _(" psect index : %u\n"),
5868 (unsigned)bfd_getl32 (esdfm
->psindx
));
5869 fprintf (file
, _(" name : %.*s\n"),
5870 esdfm
->namlng
, esdfm
->name
);
5874 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
5882 evax_bfd_print_hex (FILE *file
, const char *pfx
,
5883 const unsigned char *buf
, unsigned int len
)
5889 for (i
= 0; i
< len
; i
++)
5893 fprintf (file
, " %02x", buf
[i
]);
5906 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
5908 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
5909 (unsigned)bfd_getl32 (buf
),
5910 (unsigned)bfd_getl32 (buf
+ 16));
5911 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
5912 (unsigned)bfd_getl32 (buf
+ 4),
5913 (unsigned)bfd_getl32 (buf
+ 12),
5914 (unsigned)bfd_getl32 (buf
+ 8));
5915 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
5916 (unsigned)bfd_getl32 (buf
+ 20),
5917 (unsigned)bfd_getl32 (buf
+ 28),
5918 (unsigned)bfd_getl32 (buf
+ 24));
5920 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
5921 (unsigned)bfd_getl32 (buf
+ 32),
5922 (unsigned)bfd_getl32 (buf
+ 40),
5923 (unsigned)bfd_getl32 (buf
+ 36));
5925 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
5929 evax_bfd_print_etir (FILE *file
, const char *name
,
5930 unsigned char *rec
, unsigned int rec_len
)
5932 unsigned int off
= sizeof (struct vms_egsd
);
5933 unsigned int sec_len
= 0;
5935 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
5936 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
5937 (unsigned)sizeof (struct vms_eobjrec
));
5939 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
5941 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
5946 type
= bfd_getl16 (etir
->rectyp
);
5947 size
= bfd_getl16 (etir
->size
);
5948 buf
= rec
+ off
+ sizeof (struct vms_etir
);
5950 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
5953 case ETIR__C_STA_GBL
:
5954 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
5957 case ETIR__C_STA_LW
:
5958 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
5959 (unsigned)bfd_getl32 (buf
));
5961 case ETIR__C_STA_QW
:
5962 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
5963 (unsigned)bfd_getl32 (buf
+ 4),
5964 (unsigned)bfd_getl32 (buf
+ 0));
5966 case ETIR__C_STA_PQ
:
5967 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
5968 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
5969 (unsigned)bfd_getl32 (buf
+ 0),
5970 (unsigned)bfd_getl32 (buf
+ 8),
5971 (unsigned)bfd_getl32 (buf
+ 4));
5973 case ETIR__C_STA_LI
:
5974 fprintf (file
, _("STA_LI (stack literal)\n"));
5976 case ETIR__C_STA_MOD
:
5977 fprintf (file
, _("STA_MOD (stack module)\n"));
5979 case ETIR__C_STA_CKARG
:
5980 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
5984 fprintf (file
, _("STO_B (store byte)\n"));
5987 fprintf (file
, _("STO_W (store word)\n"));
5989 case ETIR__C_STO_LW
:
5990 fprintf (file
, _("STO_LW (store longword)\n"));
5992 case ETIR__C_STO_QW
:
5993 fprintf (file
, _("STO_QW (store quadword)\n"));
5995 case ETIR__C_STO_IMMR
:
5997 unsigned int len
= bfd_getl32 (buf
);
5999 _("STO_IMMR (store immediate repeat) %u bytes\n"),
6001 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6005 case ETIR__C_STO_GBL
:
6006 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
6009 case ETIR__C_STO_CA
:
6010 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
6013 case ETIR__C_STO_RB
:
6014 fprintf (file
, _("STO_RB (store relative branch)\n"));
6016 case ETIR__C_STO_AB
:
6017 fprintf (file
, _("STO_AB (store absolute branch)\n"));
6019 case ETIR__C_STO_OFF
:
6020 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
6022 case ETIR__C_STO_IMM
:
6024 unsigned int len
= bfd_getl32 (buf
);
6026 _("STO_IMM (store immediate) %u bytes\n"),
6028 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
6032 case ETIR__C_STO_GBL_LW
:
6033 fprintf (file
, _("STO_GBL_LW (store global longword) %.*s\n"),
6036 case ETIR__C_STO_LP_PSB
:
6037 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
6039 case ETIR__C_STO_HINT_GBL
:
6040 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
6042 case ETIR__C_STO_HINT_PS
:
6043 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
6046 case ETIR__C_OPR_NOP
:
6047 fprintf (file
, _("OPR_NOP (no-operation)\n"));
6049 case ETIR__C_OPR_ADD
:
6050 fprintf (file
, _("OPR_ADD (add)\n"));
6052 case ETIR__C_OPR_SUB
:
6053 fprintf (file
, _("OPR_SUB (substract)\n"));
6055 case ETIR__C_OPR_MUL
:
6056 fprintf (file
, _("OPR_MUL (multiply)\n"));
6058 case ETIR__C_OPR_DIV
:
6059 fprintf (file
, _("OPR_DIV (divide)\n"));
6061 case ETIR__C_OPR_AND
:
6062 fprintf (file
, _("OPR_AND (logical and)\n"));
6064 case ETIR__C_OPR_IOR
:
6065 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
6067 case ETIR__C_OPR_EOR
:
6068 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
6070 case ETIR__C_OPR_NEG
:
6071 fprintf (file
, _("OPR_NEG (negate)\n"));
6073 case ETIR__C_OPR_COM
:
6074 fprintf (file
, _("OPR_COM (complement)\n"));
6076 case ETIR__C_OPR_INSV
:
6077 fprintf (file
, _("OPR_INSV (insert field)\n"));
6079 case ETIR__C_OPR_ASH
:
6080 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6082 case ETIR__C_OPR_USH
:
6083 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6085 case ETIR__C_OPR_ROT
:
6086 fprintf (file
, _("OPR_ROT (rotate)\n"));
6088 case ETIR__C_OPR_SEL
:
6089 fprintf (file
, _("OPR_SEL (select)\n"));
6091 case ETIR__C_OPR_REDEF
:
6092 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6094 case ETIR__C_OPR_DFLIT
:
6095 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6098 case ETIR__C_STC_LP
:
6099 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6101 case ETIR__C_STC_LP_PSB
:
6103 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6104 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6105 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6106 buf
+= 4 + 1 + buf
[4];
6107 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6109 case ETIR__C_STC_GBL
:
6110 fprintf (file
, _("STC_GBL (store cond global)\n"));
6111 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6112 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6114 case ETIR__C_STC_GCA
:
6115 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6116 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6117 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6119 case ETIR__C_STC_PS
:
6120 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6122 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6123 (unsigned)bfd_getl32 (buf
),
6124 (unsigned)bfd_getl32 (buf
+ 4),
6125 (unsigned)bfd_getl32 (buf
+ 12),
6126 (unsigned)bfd_getl32 (buf
+ 8));
6128 case ETIR__C_STC_NOP_GBL
:
6129 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6130 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6132 case ETIR__C_STC_NOP_PS
:
6133 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6134 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6136 case ETIR__C_STC_BSR_GBL
:
6137 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6138 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6140 case ETIR__C_STC_BSR_PS
:
6141 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6142 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6144 case ETIR__C_STC_LDA_GBL
:
6145 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6146 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6148 case ETIR__C_STC_LDA_PS
:
6149 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6150 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6152 case ETIR__C_STC_BOH_GBL
:
6153 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6154 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6156 case ETIR__C_STC_BOH_PS
:
6157 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6158 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6160 case ETIR__C_STC_NBH_GBL
:
6162 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6164 case ETIR__C_STC_NBH_PS
:
6166 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6169 case ETIR__C_CTL_SETRB
:
6170 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6173 case ETIR__C_CTL_AUGRB
:
6175 unsigned int val
= bfd_getl32 (buf
);
6176 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6179 case ETIR__C_CTL_DFLOC
:
6180 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6182 case ETIR__C_CTL_STLOC
:
6183 fprintf (file
, _("CTL_STLOC (set location)\n"));
6185 case ETIR__C_CTL_STKDL
:
6186 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6189 fprintf (file
, _("*unhandled*\n"));
6197 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6199 bfd_boolean is_first
= TRUE
;
6200 bfd_boolean has_records
= FALSE
;
6204 unsigned int rec_len
;
6205 unsigned int pad_len
;
6207 unsigned int hdr_size
;
6212 unsigned char buf
[6];
6217 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6219 fprintf (file
, _("cannot read GST record length\n"));
6222 rec_len
= bfd_getl16 (buf
+ 0);
6223 if (rec_len
== bfd_getl16 (buf
+ 4)
6224 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6226 /* The format is raw: record-size, type, record-size. */
6228 pad_len
= (rec_len
+ 1) & ~1U;
6231 else if (rec_len
== EOBJ__C_EMH
)
6233 has_records
= FALSE
;
6234 pad_len
= bfd_getl16 (buf
+ 2);
6240 fprintf (file
, _("cannot find EMH in first GST record\n"));
6243 rec
= bfd_malloc (pad_len
);
6244 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6248 unsigned int rec_len2
= 0;
6249 unsigned char hdr
[4];
6253 unsigned char buf_len
[2];
6255 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6256 != sizeof (buf_len
))
6258 fprintf (file
, _("cannot read GST record length\n"));
6261 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6264 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6266 fprintf (file
, _("cannot read GST record header\n"));
6269 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6271 pad_len
= (rec_len
+ 1) & ~1U;
6274 rec
= bfd_malloc (pad_len
);
6275 memcpy (rec
, hdr
, sizeof (hdr
));
6276 hdr_size
= sizeof (hdr
);
6277 if (has_records
&& rec_len2
!= rec_len
)
6279 fprintf (file
, _(" corrupted GST\n"));
6284 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6285 != pad_len
- hdr_size
)
6287 fprintf (file
, _("cannot read GST record\n"));
6291 type
= (unsigned)bfd_getl16 (rec
);
6296 evax_bfd_print_emh (file
, rec
, rec_len
);
6299 evax_bfd_print_egsd (file
, rec
, rec_len
);
6302 evax_bfd_print_eeom (file
, rec
, rec_len
);
6307 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6310 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6313 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6316 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6324 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6325 unsigned int stride
)
6333 count
= bfd_getl32 (rel
+ 0);
6337 base
= bfd_getl32 (rel
+ 4);
6339 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6343 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6349 val
= bfd_getl32 (rel
);
6352 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6354 for (k
= 0; k
< 32; k
++)
6359 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6374 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6381 count
= bfd_getl32 (rel
+ 0);
6384 fprintf (file
, _(" image %u (%u entries)\n"),
6385 (unsigned)bfd_getl32 (rel
+ 4), count
);
6387 for (j
= 0; j
< count
; j
++)
6389 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6390 (unsigned)bfd_getl32 (rel
+ 0),
6391 (unsigned)bfd_getl32 (rel
+ 4));
6398 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6407 count
= bfd_getl32 (rel
+ 0);
6410 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6411 (unsigned)bfd_getl32 (rel
+ 4), count
);
6413 for (j
= 0; j
< count
; j
++)
6417 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6432 evax_bfd_print_indent (int indent
, FILE *file
)
6434 for (; indent
; indent
--)
6439 evax_bfd_get_dsc_name (unsigned int v
)
6443 case DSC__K_DTYPE_Z
:
6444 return "Z (Unspecified)";
6445 case DSC__K_DTYPE_V
:
6447 case DSC__K_DTYPE_BU
:
6448 return "BU (Byte logical)";
6449 case DSC__K_DTYPE_WU
:
6450 return "WU (Word logical)";
6451 case DSC__K_DTYPE_LU
:
6452 return "LU (Longword logical)";
6453 case DSC__K_DTYPE_QU
:
6454 return "QU (Quadword logical)";
6455 case DSC__K_DTYPE_B
:
6456 return "B (Byte integer)";
6457 case DSC__K_DTYPE_W
:
6458 return "W (Word integer)";
6459 case DSC__K_DTYPE_L
:
6460 return "L (Longword integer)";
6461 case DSC__K_DTYPE_Q
:
6462 return "Q (Quadword integer)";
6463 case DSC__K_DTYPE_F
:
6464 return "F (Single-precision floating)";
6465 case DSC__K_DTYPE_D
:
6466 return "D (Double-precision floating)";
6467 case DSC__K_DTYPE_FC
:
6468 return "FC (Complex)";
6469 case DSC__K_DTYPE_DC
:
6470 return "DC (Double-precision Complex)";
6471 case DSC__K_DTYPE_T
:
6472 return "T (ASCII text string)";
6473 case DSC__K_DTYPE_NU
:
6474 return "NU (Numeric string, unsigned)";
6475 case DSC__K_DTYPE_NL
:
6476 return "NL (Numeric string, left separate sign)";
6477 case DSC__K_DTYPE_NLO
:
6478 return "NLO (Numeric string, left overpunched sign)";
6479 case DSC__K_DTYPE_NR
:
6480 return "NR (Numeric string, right separate sign)";
6481 case DSC__K_DTYPE_NRO
:
6482 return "NRO (Numeric string, right overpunched sig)";
6483 case DSC__K_DTYPE_NZ
:
6484 return "NZ (Numeric string, zoned sign)";
6485 case DSC__K_DTYPE_P
:
6486 return "P (Packed decimal string)";
6487 case DSC__K_DTYPE_ZI
:
6488 return "ZI (Sequence of instructions)";
6489 case DSC__K_DTYPE_ZEM
:
6490 return "ZEM (Procedure entry mask)";
6491 case DSC__K_DTYPE_DSC
:
6492 return "DSC (Descriptor, used for arrays of dyn strings)";
6493 case DSC__K_DTYPE_OU
:
6494 return "OU (Octaword logical)";
6495 case DSC__K_DTYPE_O
:
6496 return "O (Octaword integer)";
6497 case DSC__K_DTYPE_G
:
6498 return "G (Double precision G floating, 64 bit)";
6499 case DSC__K_DTYPE_H
:
6500 return "H (Quadruple precision floating, 128 bit)";
6501 case DSC__K_DTYPE_GC
:
6502 return "GC (Double precision complex, G floating)";
6503 case DSC__K_DTYPE_HC
:
6504 return "HC (Quadruple precision complex, H floating)";
6505 case DSC__K_DTYPE_CIT
:
6506 return "CIT (COBOL intermediate temporary)";
6507 case DSC__K_DTYPE_BPV
:
6508 return "BPV (Bound Procedure Value)";
6509 case DSC__K_DTYPE_BLV
:
6510 return "BLV (Bound Label Value)";
6511 case DSC__K_DTYPE_VU
:
6512 return "VU (Bit Unaligned)";
6513 case DSC__K_DTYPE_ADT
:
6514 return "ADT (Absolute Date-Time)";
6515 case DSC__K_DTYPE_VT
:
6516 return "VT (Varying Text)";
6517 case DSC__K_DTYPE_T2
:
6518 return "T2 (16-bit char)";
6519 case DSC__K_DTYPE_VT2
:
6520 return "VT2 (16-bit varying char)";
6522 return "?? (unknown)";
6527 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6529 unsigned char bclass
= buf
[3];
6530 unsigned char dtype
= buf
[2];
6531 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6532 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6534 evax_bfd_print_indent (indent
, file
);
6536 if (len
== 1 && pointer
== 0xffffffffUL
)
6539 fprintf (file
, _("64 bits *unhandled*\n"));
6543 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6544 bclass
, dtype
, len
, pointer
);
6547 case DSC__K_CLASS_NCA
:
6549 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6551 const unsigned char *b
;
6553 evax_bfd_print_indent (indent
, file
);
6554 fprintf (file
, _("non-contiguous array of %s\n"),
6555 evax_bfd_get_dsc_name (dsc
->dtype
));
6556 evax_bfd_print_indent (indent
+ 1, file
);
6558 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6559 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6560 evax_bfd_print_indent (indent
+ 1, file
);
6562 _("arsize: %u, a0: 0x%08x\n"),
6563 (unsigned)bfd_getl32 (dsc
->arsize
),
6564 (unsigned)bfd_getl32 (dsc
->a0
));
6565 evax_bfd_print_indent (indent
+ 1, file
);
6566 fprintf (file
, _("Strides:\n"));
6567 b
= buf
+ sizeof (*dsc
);
6568 for (i
= 0; i
< dsc
->dimct
; i
++)
6570 evax_bfd_print_indent (indent
+ 2, file
);
6571 fprintf (file
, _("[%u]: %u\n"), i
+ 1,
6572 (unsigned)bfd_getl32 (b
));
6575 evax_bfd_print_indent (indent
+ 1, file
);
6576 fprintf (file
, _("Bounds:\n"));
6577 b
= buf
+ sizeof (*dsc
);
6578 for (i
= 0; i
< dsc
->dimct
; i
++)
6580 evax_bfd_print_indent (indent
+ 2, file
);
6581 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6582 (unsigned)bfd_getl32 (b
+ 0),
6583 (unsigned)bfd_getl32 (b
+ 4));
6588 case DSC__K_CLASS_UBS
:
6590 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6592 evax_bfd_print_indent (indent
, file
);
6593 fprintf (file
, _("unaligned bit-string of %s\n"),
6594 evax_bfd_get_dsc_name (ubs
->dtype
));
6595 evax_bfd_print_indent (indent
+ 1, file
);
6597 _("base: %u, pos: %u\n"),
6598 (unsigned)bfd_getl32 (ubs
->base
),
6599 (unsigned)bfd_getl32 (ubs
->pos
));
6603 fprintf (file
, _("*unhandled*\n"));
6610 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6612 unsigned int vflags
= buf
[0];
6613 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6614 unsigned int len
= 5;
6616 evax_bfd_print_indent (indent
, file
);
6617 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6622 case DST__K_VFLAGS_NOVAL
:
6623 fprintf (file
, _("(no value)\n"));
6625 case DST__K_VFLAGS_NOTACTIVE
:
6626 fprintf (file
, _("(not active)\n"));
6628 case DST__K_VFLAGS_UNALLOC
:
6629 fprintf (file
, _("(not allocated)\n"));
6631 case DST__K_VFLAGS_DSC
:
6632 fprintf (file
, _("(descriptor)\n"));
6633 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6635 case DST__K_VFLAGS_TVS
:
6636 fprintf (file
, _("(trailing value)\n"));
6638 case DST__K_VS_FOLLOWS
:
6639 fprintf (file
, _("(value spec follows)\n"));
6641 case DST__K_VFLAGS_BITOFFS
:
6642 fprintf (file
, _("(at bit offset %u)\n"), value
);
6645 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6646 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6647 vflags
& DST__K_DISP
? 1 : 0,
6648 vflags
& DST__K_INDIR
? 1 : 0);
6649 switch (vflags
& DST__K_VALKIND_MASK
)
6651 case DST__K_VALKIND_LITERAL
:
6652 fputs (_("literal"), file
);
6654 case DST__K_VALKIND_ADDR
:
6655 fputs (_("address"), file
);
6657 case DST__K_VALKIND_DESC
:
6658 fputs (_("desc"), file
);
6660 case DST__K_VALKIND_REG
:
6661 fputs (_("reg"), file
);
6664 fputs (")\n", file
);
6671 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6673 unsigned char kind
= buf
[2];
6674 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6676 evax_bfd_print_indent (indent
, file
);
6677 fprintf (file
, ("len: %2u, kind: %2u "), len
, kind
);
6681 case DST__K_TS_ATOM
:
6682 fprintf (file
, ("atomic, type=0x%02x %s\n"),
6683 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6686 fprintf (file
, ("indirect, defined at 0x%08x\n"),
6687 (unsigned)bfd_getl32 (buf
));
6689 case DST__K_TS_TPTR
:
6690 fprintf (file
, ("typed pointer\n"));
6691 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6694 fprintf (file
, ("pointer\n"));
6696 case DST__K_TS_ARRAY
:
6698 const unsigned char *vs
;
6699 unsigned int vec_len
;
6702 fprintf (file
, ("array, dim: %u, bitmap: "), buf
[0]);
6703 vec_len
= (buf
[0] + 1 + 7) / 8;
6704 for (i
= 0; i
< vec_len
; i
++)
6705 fprintf (file
, " %02x", buf
[i
+ 1]);
6707 vs
= buf
+ 1 + vec_len
;
6708 evax_bfd_print_indent (indent
, file
);
6709 fprintf (file
, ("array descriptor:\n"));
6710 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6711 for (i
= 0; i
< buf
[0] + 1U; i
++)
6712 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6714 evax_bfd_print_indent (indent
, file
);
6716 fprintf (file
, ("type spec for element:\n"));
6718 fprintf (file
, ("type spec for subscript %u:\n"), i
);
6719 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6720 vs
+= bfd_getl16 (vs
);
6725 fprintf (file
, ("*unhandled*\n"));
6730 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6732 unsigned int off
= 0;
6733 unsigned int pc
= 0;
6734 unsigned int line
= 0;
6736 fprintf (file
, _("Debug symbol table:\n"));
6738 while (dst_size
> 0)
6740 struct vms_dst_header dsth
;
6745 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6747 fprintf (file
, _("cannot read DST header\n"));
6750 len
= bfd_getl16 (dsth
.length
);
6751 type
= bfd_getl16 (dsth
.type
);
6752 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
6762 len
-= sizeof (dsth
);
6763 buf
= bfd_malloc (len
);
6764 if (bfd_bread (buf
, len
, abfd
) != len
)
6766 fprintf (file
, _("cannot read DST symbol\n"));
6771 case DSC__K_DTYPE_V
:
6772 case DSC__K_DTYPE_BU
:
6773 case DSC__K_DTYPE_WU
:
6774 case DSC__K_DTYPE_LU
:
6775 case DSC__K_DTYPE_QU
:
6776 case DSC__K_DTYPE_B
:
6777 case DSC__K_DTYPE_W
:
6778 case DSC__K_DTYPE_L
:
6779 case DSC__K_DTYPE_Q
:
6780 case DSC__K_DTYPE_F
:
6781 case DSC__K_DTYPE_D
:
6782 case DSC__K_DTYPE_FC
:
6783 case DSC__K_DTYPE_DC
:
6784 case DSC__K_DTYPE_T
:
6785 case DSC__K_DTYPE_NU
:
6786 case DSC__K_DTYPE_NL
:
6787 case DSC__K_DTYPE_NLO
:
6788 case DSC__K_DTYPE_NR
:
6789 case DSC__K_DTYPE_NRO
:
6790 case DSC__K_DTYPE_NZ
:
6791 case DSC__K_DTYPE_P
:
6792 case DSC__K_DTYPE_ZI
:
6793 case DSC__K_DTYPE_ZEM
:
6794 case DSC__K_DTYPE_DSC
:
6795 case DSC__K_DTYPE_OU
:
6796 case DSC__K_DTYPE_O
:
6797 case DSC__K_DTYPE_G
:
6798 case DSC__K_DTYPE_H
:
6799 case DSC__K_DTYPE_GC
:
6800 case DSC__K_DTYPE_HC
:
6801 case DSC__K_DTYPE_CIT
:
6802 case DSC__K_DTYPE_BPV
:
6803 case DSC__K_DTYPE_BLV
:
6804 case DSC__K_DTYPE_VU
:
6805 case DSC__K_DTYPE_ADT
:
6806 case DSC__K_DTYPE_VT
:
6807 case DSC__K_DTYPE_T2
:
6808 case DSC__K_DTYPE_VT2
:
6809 fprintf (file
, _("standard data: %s\n"),
6810 evax_bfd_get_dsc_name (type
));
6811 evax_bfd_print_valspec (buf
, 4, file
);
6812 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
6816 struct vms_dst_modbeg
*dst
= (void *)buf
;
6817 const char *name
= (const char *)buf
+ sizeof (*dst
);
6819 fprintf (file
, _("modbeg\n"));
6820 fprintf (file
, _(" flags: %d, language: %u, "
6821 "major: %u, minor: %u\n"),
6823 (unsigned)bfd_getl32 (dst
->language
),
6824 (unsigned)bfd_getl16 (dst
->major
),
6825 (unsigned)bfd_getl16 (dst
->minor
));
6826 fprintf (file
, _(" module name: %.*s\n"),
6828 name
+= name
[0] + 1;
6829 fprintf (file
, _(" compiler : %.*s\n"),
6834 fprintf (file
, _("modend\n"));
6838 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
6839 const char *name
= (const char *)buf
+ sizeof (*dst
);
6841 fputs (_("rtnbeg\n"), file
);
6842 fprintf (file
, _(" flags: %u, address: 0x%08x, "
6843 "pd-address: 0x%08x\n"),
6845 (unsigned)bfd_getl32 (dst
->address
),
6846 (unsigned)bfd_getl32 (dst
->pd_address
));
6847 fprintf (file
, _(" routine name: %.*s\n"),
6853 struct vms_dst_rtnend
*dst
= (void *)buf
;
6855 fprintf (file
, _("rtnend: size 0x%08x\n"),
6856 (unsigned)bfd_getl32 (dst
->size
));
6861 struct vms_dst_prolog
*dst
= (void *)buf
;
6863 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
6864 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
6869 struct vms_dst_epilog
*dst
= (void *)buf
;
6871 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
6872 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
6877 struct vms_dst_blkbeg
*dst
= (void *)buf
;
6878 const char *name
= (const char *)buf
+ sizeof (*dst
);
6880 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6881 (unsigned)bfd_getl32 (dst
->address
),
6887 struct vms_dst_blkend
*dst
= (void *)buf
;
6889 fprintf (file
, _("blkend: size: 0x%08x\n"),
6890 (unsigned)bfd_getl32 (dst
->size
));
6893 case DST__K_TYPSPEC
:
6895 fprintf (file
, _("typspec (len: %u)\n"), len
);
6896 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
6897 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
6902 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
6903 evax_bfd_print_valspec (buf
, 4, file
);
6908 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
6909 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
6911 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
6912 evax_bfd_print_valspec (buf
, 4, file
);
6913 fprintf (file
, (" len: %u bits\n"),
6914 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
6918 fprintf (file
, _("recend\n"));
6920 case DST__K_ENUMBEG
:
6921 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
6922 buf
[0], buf
[1], buf
+ 2);
6924 case DST__K_ENUMELT
:
6925 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
6926 evax_bfd_print_valspec (buf
, 4, file
);
6928 case DST__K_ENUMEND
:
6929 fprintf (file
, _("enumend\n"));
6933 struct vms_dst_label
*lab
= (void *)buf
;
6934 fprintf (file
, ("label, name: %.*s\n"),
6935 lab
->name
[0], lab
->name
+ 1);
6936 fprintf (file
, (" address: 0x%08x\n"),
6937 (unsigned)bfd_getl32 (lab
->value
));
6940 case DST__K_DIS_RANGE
:
6942 unsigned int cnt
= bfd_getl32 (buf
);
6943 unsigned char *rng
= buf
+ 4;
6946 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
6947 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
6948 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
6949 (unsigned)bfd_getl32 (rng
),
6950 (unsigned)bfd_getl32 (rng
+ 4));
6954 case DST__K_LINE_NUM
:
6956 unsigned char *buf_orig
= buf
;
6958 fprintf (file
, _("line num (len: %u)\n"), len
);
6963 unsigned char cmdlen
;
6973 case DST__K_DELTA_PC_W
:
6974 val
= bfd_getl16 (buf
+ 1);
6975 fprintf (file
, _("delta_pc_w %u\n"), val
);
6980 case DST__K_INCR_LINUM
:
6982 fprintf (file
, _("incr_linum(b): +%u\n"), val
);
6986 case DST__K_INCR_LINUM_W
:
6987 val
= bfd_getl16 (buf
+ 1);
6988 fprintf (file
, _("incr_linum_w: +%u\n"), val
);
6992 case DST__K_INCR_LINUM_L
:
6993 val
= bfd_getl32 (buf
+ 1);
6994 fprintf (file
, _("incr_linum_l: +%u\n"), val
);
6998 case DST__K_SET_LINUM
:
6999 line
= bfd_getl16 (buf
+ 1);
7000 fprintf (file
, _("set_line_num(w) %u\n"), line
);
7003 case DST__K_SET_LINUM_B
:
7005 fprintf (file
, _("set_line_num_b %u\n"), line
);
7008 case DST__K_SET_LINUM_L
:
7009 line
= bfd_getl32 (buf
+ 1);
7010 fprintf (file
, _("set_line_num_l %u\n"), line
);
7013 case DST__K_SET_ABS_PC
:
7014 pc
= bfd_getl32 (buf
+ 1);
7015 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
7018 case DST__K_DELTA_PC_L
:
7019 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
7020 (unsigned)bfd_getl32 (buf
+ 1));
7024 fprintf (file
, _("term(b): 0x%02x"), buf
[1]);
7026 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7030 val
= bfd_getl16 (buf
+ 1);
7031 fprintf (file
, _("term_w: 0x%04x"), val
);
7033 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
7039 fprintf (file
, _("delta pc +%-4d"), -cmd
);
7040 line
++; /* FIXME: curr increment. */
7042 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
7047 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7060 unsigned char *buf_orig
= buf
;
7062 fprintf (file
, _("source (len: %u)\n"), len
);
7066 signed char cmd
= buf
[0];
7067 unsigned char cmdlen
= 0;
7071 case DST__K_SRC_DECLFILE
:
7073 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
7076 fprintf (file
, _(" declfile: len: %u, flags: %u, "
7078 src
->length
, src
->flags
,
7079 (unsigned)bfd_getl16 (src
->fileid
));
7080 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7081 "ebk: 0x%08x, ffb: 0x%04x, "
7083 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7084 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7085 (unsigned)bfd_getl32 (src
->rms_ebk
),
7086 (unsigned)bfd_getl16 (src
->rms_ffb
),
7088 name
= (const char *)buf
+ 1 + sizeof (*src
);
7089 fprintf (file
, _(" filename : %.*s\n"),
7091 name
+= name
[0] + 1;
7092 fprintf (file
, _(" module name: %.*s\n"),
7094 cmdlen
= 2 + src
->length
;
7097 case DST__K_SRC_SETFILE
:
7098 fprintf (file
, _(" setfile %u\n"),
7099 (unsigned)bfd_getl16 (buf
+ 1));
7102 case DST__K_SRC_SETREC_W
:
7103 fprintf (file
, _(" setrec %u\n"),
7104 (unsigned)bfd_getl16 (buf
+ 1));
7107 case DST__K_SRC_SETREC_L
:
7108 fprintf (file
, _(" setrec %u\n"),
7109 (unsigned)bfd_getl32 (buf
+ 1));
7112 case DST__K_SRC_SETLNUM_W
:
7113 fprintf (file
, _(" setlnum %u\n"),
7114 (unsigned)bfd_getl16 (buf
+ 1));
7117 case DST__K_SRC_SETLNUM_L
:
7118 fprintf (file
, _(" setlnum %u\n"),
7119 (unsigned)bfd_getl32 (buf
+ 1));
7122 case DST__K_SRC_DEFLINES_W
:
7123 fprintf (file
, _(" deflines %u\n"),
7124 (unsigned)bfd_getl16 (buf
+ 1));
7127 case DST__K_SRC_DEFLINES_B
:
7128 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7131 case DST__K_SRC_FORMFEED
:
7132 fprintf (file
, _(" formfeed\n"));
7136 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7148 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7156 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7158 struct vms_eihd eihd
;
7161 unsigned int eiha_off
;
7162 unsigned int eihi_off
;
7163 unsigned int eihs_off
;
7164 unsigned int eisd_off
;
7165 unsigned int eihef_off
= 0;
7166 unsigned int eihnp_off
= 0;
7167 unsigned int dmt_vbn
= 0;
7168 unsigned int dmt_size
= 0;
7169 unsigned int dst_vbn
= 0;
7170 unsigned int dst_size
= 0;
7171 unsigned int gst_vbn
= 0;
7172 unsigned int gst_size
= 0;
7173 unsigned int eiaf_vbn
= 0;
7174 unsigned int eiaf_size
= 0;
7175 unsigned int eihvn_off
;
7177 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7178 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7180 fprintf (file
, _("cannot read EIHD\n"));
7183 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7184 (unsigned)bfd_getl32 (eihd
.size
),
7185 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7186 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7187 (unsigned)bfd_getl32 (eihd
.majorid
),
7188 (unsigned)bfd_getl32 (eihd
.minorid
));
7190 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7194 name
= _("executable");
7197 name
= _("linkable image");
7200 name
= _("unknown");
7203 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7205 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7208 case EIHD__C_NATIVE
:
7215 name
= _("unknown");
7218 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7220 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7221 eiha_off
= bfd_getl32 (eihd
.activoff
);
7222 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7223 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7224 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7225 "imgid: %u, patch: %u\n"),
7226 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7227 (unsigned)bfd_getl32 (eihd
.patchoff
));
7228 fprintf (file
, _(" fixup info rva: "));
7229 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7230 fprintf (file
, _(", symbol vector rva: "));
7231 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7232 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7233 fprintf (file
, _("\n"
7234 " version array off: %u\n"),
7237 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7238 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7239 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7240 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7241 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7242 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7243 fprintf (file
, _(" linker flags: %08x:"), val
);
7244 if (val
& EIHD__M_LNKDEBUG
)
7245 fprintf (file
, " LNKDEBUG");
7246 if (val
& EIHD__M_LNKNOTFR
)
7247 fprintf (file
, " LNKNOTFR");
7248 if (val
& EIHD__M_NOP0BUFS
)
7249 fprintf (file
, " NOP0BUFS");
7250 if (val
& EIHD__M_PICIMG
)
7251 fprintf (file
, " PICIMG");
7252 if (val
& EIHD__M_P0IMAGE
)
7253 fprintf (file
, " P0IMAGE");
7254 if (val
& EIHD__M_DBGDMT
)
7255 fprintf (file
, " DBGDMT");
7256 if (val
& EIHD__M_INISHR
)
7257 fprintf (file
, " INISHR");
7258 if (val
& EIHD__M_XLATED
)
7259 fprintf (file
, " XLATED");
7260 if (val
& EIHD__M_BIND_CODE_SEC
)
7261 fprintf (file
, " BIND_CODE_SEC");
7262 if (val
& EIHD__M_BIND_DATA_SEC
)
7263 fprintf (file
, " BIND_DATA_SEC");
7264 if (val
& EIHD__M_MKTHREADS
)
7265 fprintf (file
, " MKTHREADS");
7266 if (val
& EIHD__M_UPCALLS
)
7267 fprintf (file
, " UPCALLS");
7268 if (val
& EIHD__M_OMV_READY
)
7269 fprintf (file
, " OMV_READY");
7270 if (val
& EIHD__M_EXT_BIND_SECT
)
7271 fprintf (file
, " EXT_BIND_SECT");
7272 fprintf (file
, "\n");
7273 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7274 "match ctrl: %u, symvect_size: %u\n"),
7275 (unsigned)bfd_getl32 (eihd
.ident
),
7276 (unsigned)bfd_getl32 (eihd
.sysver
),
7278 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7279 fprintf (file
, _(" BPAGE: %u"),
7280 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7281 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7283 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7284 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7285 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7286 eihef_off
, eihnp_off
);
7288 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7292 struct vms_eihvn eihvn
;
7296 fprintf (file
, _("system version array information:\n"));
7297 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7298 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7300 fprintf (file
, _("cannot read EIHVN header\n"));
7303 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7304 for (j
= 0; j
< 32; j
++)
7305 if (mask
& (1 << j
))
7307 struct vms_eihvn_subversion ver
;
7308 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7310 fprintf (file
, _("cannot read EIHVN version\n"));
7313 fprintf (file
, _(" %02u "), j
);
7316 case EIHVN__BASE_IMAGE_BIT
:
7317 fputs (_("BASE_IMAGE "), file
);
7319 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7320 fputs (_("MEMORY_MANAGEMENT"), file
);
7323 fputs (_("IO "), file
);
7325 case EIHVN__FILES_VOLUMES_BIT
:
7326 fputs (_("FILES_VOLUMES "), file
);
7328 case EIHVN__PROCESS_SCHED_BIT
:
7329 fputs (_("PROCESS_SCHED "), file
);
7331 case EIHVN__SYSGEN_BIT
:
7332 fputs (_("SYSGEN "), file
);
7334 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7335 fputs (_("CLUSTERS_LOCKMGR "), file
);
7337 case EIHVN__LOGICAL_NAMES_BIT
:
7338 fputs (_("LOGICAL_NAMES "), file
);
7340 case EIHVN__SECURITY_BIT
:
7341 fputs (_("SECURITY "), file
);
7343 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7344 fputs (_("IMAGE_ACTIVATOR "), file
);
7346 case EIHVN__NETWORKS_BIT
:
7347 fputs (_("NETWORKS "), file
);
7349 case EIHVN__COUNTERS_BIT
:
7350 fputs (_("COUNTERS "), file
);
7352 case EIHVN__STABLE_BIT
:
7353 fputs (_("STABLE "), file
);
7355 case EIHVN__MISC_BIT
:
7356 fputs (_("MISC "), file
);
7358 case EIHVN__CPU_BIT
:
7359 fputs (_("CPU "), file
);
7361 case EIHVN__VOLATILE_BIT
:
7362 fputs (_("VOLATILE "), file
);
7364 case EIHVN__SHELL_BIT
:
7365 fputs (_("SHELL "), file
);
7367 case EIHVN__POSIX_BIT
:
7368 fputs (_("POSIX "), file
);
7370 case EIHVN__MULTI_PROCESSING_BIT
:
7371 fputs (_("MULTI_PROCESSING "), file
);
7373 case EIHVN__GALAXY_BIT
:
7374 fputs (_("GALAXY "), file
);
7377 fputs (_("*unknown* "), file
);
7380 fprintf (file
, _(": %u.%u\n"),
7381 (unsigned)bfd_getl16 (ver
.major
),
7382 (unsigned)bfd_getl16 (ver
.minor
));
7388 struct vms_eiha eiha
;
7390 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7391 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7393 fprintf (file
, _("cannot read EIHA\n"));
7396 fprintf (file
, _("Image activation: (size=%u)\n"),
7397 (unsigned)bfd_getl32 (eiha
.size
));
7398 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7399 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7400 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7401 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7402 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7403 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7404 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7405 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7406 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7407 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7408 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7409 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7410 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7411 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7412 (unsigned)bfd_getl32 (eiha
.inishr
));
7416 struct vms_eihi eihi
;
7418 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7419 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7421 fprintf (file
, _("cannot read EIHI\n"));
7424 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7425 (unsigned)bfd_getl32 (eihi
.majorid
),
7426 (unsigned)bfd_getl32 (eihi
.minorid
));
7427 fprintf (file
, _(" image name : %.*s\n"),
7428 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7429 fprintf (file
, _(" link time : %s\n"),
7430 vms_time_to_str (eihi
.linktime
));
7431 fprintf (file
, _(" image ident : %.*s\n"),
7432 eihi
.imgid
[0], eihi
.imgid
+ 1);
7433 fprintf (file
, _(" linker ident : %.*s\n"),
7434 eihi
.linkid
[0], eihi
.linkid
+ 1);
7435 fprintf (file
, _(" image build ident: %.*s\n"),
7436 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7440 struct vms_eihs eihs
;
7442 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7443 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7445 fprintf (file
, _("cannot read EIHS\n"));
7448 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7449 (unsigned)bfd_getl32 (eihs
.majorid
),
7450 (unsigned)bfd_getl32 (eihs
.minorid
));
7451 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7452 dst_size
= bfd_getl32 (eihs
.dstsize
);
7453 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7454 dst_vbn
, dst_size
, dst_size
);
7455 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7456 gst_size
= bfd_getl32 (eihs
.gstsize
);
7457 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7459 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7460 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7461 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7464 while (eisd_off
!= 0)
7466 struct vms_eisd eisd
;
7471 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7472 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7474 fprintf (file
, _("cannot read EISD\n"));
7477 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7478 if (len
!= (unsigned)-1)
7482 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7484 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7485 "size: %u, offset: %u)\n"),
7486 (unsigned)bfd_getl32 (eisd
.majorid
),
7487 (unsigned)bfd_getl32 (eisd
.minorid
),
7491 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7492 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7493 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7494 (unsigned)bfd_getl32 (eisd
.secsize
));
7495 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7496 fprintf (file
, _(" flags: 0x%04x"), val
);
7497 if (val
& EISD__M_GBL
)
7498 fprintf (file
, " GBL");
7499 if (val
& EISD__M_CRF
)
7500 fprintf (file
, " CRF");
7501 if (val
& EISD__M_DZRO
)
7502 fprintf (file
, " DZRO");
7503 if (val
& EISD__M_WRT
)
7504 fprintf (file
, " WRT");
7505 if (val
& EISD__M_INITALCODE
)
7506 fprintf (file
, " INITALCODE");
7507 if (val
& EISD__M_BASED
)
7508 fprintf (file
, " BASED");
7509 if (val
& EISD__M_FIXUPVEC
)
7510 fprintf (file
, " FIXUPVEC");
7511 if (val
& EISD__M_RESIDENT
)
7512 fprintf (file
, " RESIDENT");
7513 if (val
& EISD__M_VECTOR
)
7514 fprintf (file
, " VECTOR");
7515 if (val
& EISD__M_PROTECT
)
7516 fprintf (file
, " PROTECT");
7517 if (val
& EISD__M_LASTCLU
)
7518 fprintf (file
, " LASTCLU");
7519 if (val
& EISD__M_EXE
)
7520 fprintf (file
, " EXE");
7521 if (val
& EISD__M_NONSHRADR
)
7522 fprintf (file
, " NONSHRADR");
7523 if (val
& EISD__M_QUAD_LENGTH
)
7524 fprintf (file
, " QUAD_LENGTH");
7525 if (val
& EISD__M_ALLOC_64BIT
)
7526 fprintf (file
, " ALLOC_64BIT");
7527 fprintf (file
, "\n");
7528 if (val
& EISD__M_FIXUPVEC
)
7530 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7531 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7533 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7534 (unsigned)bfd_getl32 (eisd
.vbn
),
7535 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7538 case EISD__K_NORMAL
:
7539 fputs (_("NORMAL"), file
);
7541 case EISD__K_SHRFXD
:
7542 fputs (_("SHRFXD"), file
);
7544 case EISD__K_PRVFXD
:
7545 fputs (_("PRVFXD"), file
);
7547 case EISD__K_SHRPIC
:
7548 fputs (_("SHRPIC"), file
);
7550 case EISD__K_PRVPIC
:
7551 fputs (_("PRVPIC"), file
);
7553 case EISD__K_USRSTACK
:
7554 fputs (_("USRSTACK"), file
);
7557 fputs (_("*unknown*"), file
);
7560 fputs (_(")\n"), file
);
7561 if (val
& EISD__M_GBL
)
7562 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7563 (unsigned)bfd_getl32 (eisd
.ident
),
7564 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7570 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7572 fprintf (file
, _("cannot read DMT\n"));
7576 fprintf (file
, _("Debug module table:\n"));
7578 while (dmt_size
> 0)
7580 struct vms_dmt_header dmth
;
7583 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7585 fprintf (file
, _("cannot read DMT header\n"));
7588 count
= bfd_getl16 (dmth
.psect_count
);
7590 _(" module offset: 0x%08x, size: 0x%08x, (%u psects)\n"),
7591 (unsigned)bfd_getl32 (dmth
.modbeg
),
7592 (unsigned)bfd_getl32 (dmth
.size
), count
);
7593 dmt_size
-= sizeof (dmth
);
7596 struct vms_dmt_psect dmtp
;
7598 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7600 fprintf (file
, _("cannot read DMT psect\n"));
7603 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7604 (unsigned)bfd_getl32 (dmtp
.start
),
7605 (unsigned)bfd_getl32 (dmtp
.length
));
7607 dmt_size
-= sizeof (dmtp
);
7614 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7616 fprintf (file
, _("cannot read DST\n"));
7620 evax_bfd_print_dst (abfd
, dst_size
, file
);
7624 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7626 fprintf (file
, _("cannot read GST\n"));
7630 fprintf (file
, _("Global symbol table:\n"));
7631 evax_bfd_print_eobj (abfd
, file
);
7636 struct vms_eiaf
*eiaf
;
7637 unsigned int qrelfixoff
;
7638 unsigned int lrelfixoff
;
7639 unsigned int qdotadroff
;
7640 unsigned int ldotadroff
;
7641 unsigned int shrimgcnt
;
7642 unsigned int shlstoff
;
7643 unsigned int codeadroff
;
7644 unsigned int lpfixoff
;
7645 unsigned int chgprtoff
;
7647 buf
= bfd_malloc (eiaf_size
);
7649 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7650 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7652 fprintf (file
, _("cannot read EIHA\n"));
7656 eiaf
= (struct vms_eiaf
*)buf
;
7658 _("Image activator fixup: (major: %u, minor: %u)\n"),
7659 (unsigned)bfd_getl32 (eiaf
->majorid
),
7660 (unsigned)bfd_getl32 (eiaf
->minorid
));
7661 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7662 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7663 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7664 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7665 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7666 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7667 fprintf (file
, _(" size : %u\n"),
7668 (unsigned)bfd_getl32 (eiaf
->size
));
7669 fprintf (file
, _(" flags: 0x%08x\n"),
7670 (unsigned)bfd_getl32 (eiaf
->flags
));
7671 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7672 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7673 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7674 qrelfixoff
, lrelfixoff
);
7675 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7676 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7677 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7678 qdotadroff
, ldotadroff
);
7679 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7680 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7681 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7682 codeadroff
, lpfixoff
);
7683 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7684 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7685 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7686 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7687 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7688 shlstoff
, shrimgcnt
);
7689 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7690 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7691 (unsigned)bfd_getl32 (eiaf
->permctx
));
7692 fprintf (file
, _(" base_va : 0x%08x\n"),
7693 (unsigned)bfd_getl32 (eiaf
->base_va
));
7694 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7695 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7699 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7702 fprintf (file
, _(" Shareable images:\n"));
7703 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7706 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7707 j
, shl
->size
, shl
->flags
,
7708 shl
->imgnam
[0], shl
->imgnam
+ 1);
7711 if (qrelfixoff
!= 0)
7713 fprintf (file
, _(" quad-word relocation fixups:\n"));
7714 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7716 if (lrelfixoff
!= 0)
7718 fprintf (file
, _(" long-word relocation fixups:\n"));
7719 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
7721 if (qdotadroff
!= 0)
7723 fprintf (file
, _(" quad-word .address reference fixups:\n"));
7724 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
7726 if (ldotadroff
!= 0)
7728 fprintf (file
, _(" long-word .address reference fixups:\n"));
7729 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
7731 if (codeadroff
!= 0)
7733 fprintf (file
, _(" Code Address Reference Fixups:\n"));
7734 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
7738 fprintf (file
, _(" Linkage Pairs Reference Fixups:\n"));
7739 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
7743 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
7744 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
7747 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
7748 for (j
= 0; j
< count
; j
++, eicp
++)
7750 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
7752 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7753 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
7754 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
7755 (unsigned)bfd_getl32 (eicp
->size
),
7756 (unsigned)bfd_getl32 (eicp
->newprt
));
7760 fprintf (file
, "NA");
7762 case PRT__C_RESERVED
:
7763 fprintf (file
, "RES");
7766 fprintf (file
, "KW");
7769 fprintf (file
, "KR");
7772 fprintf (file
, "UW");
7775 fprintf (file
, "EW");
7778 fprintf (file
, "ERKW");
7781 fprintf (file
, "ER");
7784 fprintf (file
, "SW");
7787 fprintf (file
, "SREW");
7790 fprintf (file
, "SRKW");
7793 fprintf (file
, "SR");
7796 fprintf (file
, "URSW");
7799 fprintf (file
, "UREW");
7802 fprintf (file
, "URKW");
7805 fprintf (file
, "UR");
7819 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
7821 FILE *file
= (FILE *)ptr
;
7823 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
7824 evax_bfd_print_image (abfd
, file
);
7827 if (bfd_seek (abfd
, 0, SEEK_SET
))
7829 evax_bfd_print_eobj (abfd
, file
);
7836 /* Slurp ETIR/EDBG/ETBT VMS object records. */
7839 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
7841 asection
*cur_section
;
7842 file_ptr cur_offset
;
7843 asection
*dst_section
;
7844 file_ptr dst_offset
;
7846 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
7852 dst_section
= PRIV (dst_section
);
7856 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
7858 /* Discard the DST section. */
7862 else if (dst_section
)
7864 dst_offset
= dst_section
->output_offset
;
7865 dst_section
= dst_section
->output_section
;
7874 type
= _bfd_vms_get_object_record (abfd
);
7877 vms_debug2 ((2, "next_record failed\n"));
7883 PRIV (image_section
) = cur_section
;
7884 PRIV (image_offset
) = cur_offset
;
7885 res
= _bfd_vms_slurp_etir (abfd
, info
);
7886 cur_section
= PRIV (image_section
);
7887 cur_offset
= PRIV (image_offset
);
7891 if (dst_section
== NULL
)
7893 PRIV (image_section
) = dst_section
;
7894 PRIV (image_offset
) = dst_offset
;
7895 res
= _bfd_vms_slurp_etir (abfd
, info
);
7896 dst_offset
= PRIV (image_offset
);
7905 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
7912 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
7913 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7918 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
7921 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7923 struct alpha_vms_shlib_el
*sl
;
7924 asection
*sect
= PRIV2 (src
, image_section
);
7925 file_ptr offset
= PRIV2 (src
, image_offset
);
7927 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7928 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7929 sl
->has_fixups
= TRUE
;
7930 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
7931 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7932 sect
->output_section
->flags
|= SEC_RELOC
;
7935 /* Add a code address fixup at address SECT + OFFSET to SHLIB. */
7938 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7940 struct alpha_vms_shlib_el
*sl
;
7941 asection
*sect
= PRIV2 (src
, image_section
);
7942 file_ptr offset
= PRIV2 (src
, image_offset
);
7944 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7945 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7946 sl
->has_fixups
= TRUE
;
7947 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
7948 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7949 sect
->output_section
->flags
|= SEC_RELOC
;
7952 /* Add a quad word relocation fixup at address SECT + OFFSET to SHLIB. */
7955 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
7956 bfd
*shlib
, bfd_vma vec
)
7958 struct alpha_vms_shlib_el
*sl
;
7959 struct alpha_vms_vma_ref
*r
;
7960 asection
*sect
= PRIV2 (src
, image_section
);
7961 file_ptr offset
= PRIV2 (src
, image_offset
);
7963 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7964 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7965 sl
->has_fixups
= TRUE
;
7966 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
7967 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
7969 sect
->output_section
->flags
|= SEC_RELOC
;
7973 alpha_vms_add_fixup_lr (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
7974 unsigned int shr ATTRIBUTE_UNUSED
,
7975 bfd_vma vec ATTRIBUTE_UNUSED
)
7977 /* Not yet supported. */
7981 /* Add relocation. FIXME: Not yet emitted. */
7984 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7989 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7993 static struct bfd_hash_entry
*
7994 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
7995 struct bfd_hash_table
*table
,
7998 struct alpha_vms_link_hash_entry
*ret
=
7999 (struct alpha_vms_link_hash_entry
*) entry
;
8001 /* Allocate the structure if it has not already been allocated by a
8004 ret
= ((struct alpha_vms_link_hash_entry
*)
8005 bfd_hash_allocate (table
,
8006 sizeof (struct alpha_vms_link_hash_entry
)));
8010 /* Call the allocation method of the superclass. */
8011 ret
= ((struct alpha_vms_link_hash_entry
*)
8012 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
8017 return (struct bfd_hash_entry
*) ret
;
8020 /* Create an Alpha/VMS link hash table. */
8022 static struct bfd_link_hash_table
*
8023 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
8025 struct alpha_vms_link_hash_table
*ret
;
8026 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
8028 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
8031 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
8032 alpha_vms_link_hash_newfunc
,
8033 sizeof (struct alpha_vms_link_hash_entry
)))
8039 VEC_INIT (ret
->shrlibs
);
8046 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8050 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
8052 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
8053 struct alpha_vms_link_hash_entry
*h
;
8054 struct bfd_link_hash_entry
*h_root
;
8057 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
8060 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
8062 /* In selective_search mode, only add definition that are
8064 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
8065 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
8066 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
8072 h_root
= (struct bfd_link_hash_entry
*) h
;
8073 if (_bfd_generic_link_add_one_symbol
8074 (info
, abfd
, sym
.name
, sym
.flags
, sym
.section
, sym
.value
,
8075 NULL
, FALSE
, FALSE
, &h_root
) == FALSE
)
8077 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
8079 if ((e
->flags
& EGSY__V_DEF
)
8081 && abfd
->xvec
== info
->output_bfd
->xvec
)
8085 if (abfd
->flags
& DYNAMIC
)
8087 struct alpha_vms_shlib_el
*shlib
;
8089 /* We do not want to include any of the sections in a dynamic
8090 object in the output file. See comment in elflink.c. */
8091 bfd_section_list_clear (abfd
);
8093 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8094 struct alpha_vms_shlib_el
);
8096 VEC_INIT (shlib
->ca
);
8097 VEC_INIT (shlib
->lp
);
8098 VEC_INIT (shlib
->qr
);
8099 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8106 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8109 struct bfd_link_hash_entry
**pundef
;
8110 struct bfd_link_hash_entry
**next_pundef
;
8112 /* We only accept VMS libraries. */
8113 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8115 bfd_set_error (bfd_error_wrong_format
);
8119 /* The archive_pass field in the archive itself is used to
8120 initialize PASS, since we may search the same archive multiple
8122 pass
= ++abfd
->archive_pass
;
8124 /* Look through the list of undefined symbols. */
8125 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8127 struct bfd_link_hash_entry
*h
;
8133 next_pundef
= &(*pundef
)->u
.undef
.next
;
8135 /* When a symbol is defined, it is not necessarily removed from
8137 if (h
->type
!= bfd_link_hash_undefined
8138 && h
->type
!= bfd_link_hash_common
)
8140 /* Remove this entry from the list, for general cleanliness
8141 and because we are going to look through the list again
8142 if we search any more libraries. We can't remove the
8143 entry if it is the tail, because that would lose any
8144 entries we add to the list later on. */
8145 if (*pundef
!= info
->hash
->undefs_tail
)
8147 *pundef
= *next_pundef
;
8148 next_pundef
= pundef
;
8153 /* Look for this symbol in the archive hash table. */
8154 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8155 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8157 /* Nothing in this slot. */
8161 element
= bfd_get_elt_at_index (abfd
, symidx
);
8162 if (element
== NULL
)
8165 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8167 /* Next symbol if this archive is wrong or already handled. */
8171 if (! bfd_check_format (element
, bfd_object
))
8173 element
->archive_pass
= -1;
8177 orig_element
= element
;
8178 if (bfd_is_thin_archive (abfd
))
8180 element
= _bfd_vms_lib_get_imagelib_file (element
);
8181 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8183 orig_element
->archive_pass
= -1;
8188 /* Unlike the generic linker, we know that this element provides
8189 a definition for an undefined symbol and we know that we want
8190 to include it. We don't need to check anything. */
8191 if (!(*info
->callbacks
8192 ->add_archive_element
) (info
, element
, h
->root
.string
, &element
))
8194 if (!alpha_vms_link_add_object_symbols (element
, info
))
8197 orig_element
->archive_pass
= pass
;
8204 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8206 switch (bfd_get_format (abfd
))
8209 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8211 return alpha_vms_link_add_object_symbols (abfd
, info
);
8214 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8216 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8219 bfd_set_error (bfd_error_wrong_format
);
8225 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8227 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8228 unsigned char *content
;
8230 unsigned int sz
= 0;
8231 unsigned int lp_sz
= 0;
8232 unsigned int ca_sz
= 0;
8233 unsigned int qr_sz
= 0;
8234 unsigned int shrimg_cnt
= 0;
8235 unsigned int chgprt_num
= 0;
8236 unsigned int chgprt_sz
= 0;
8237 struct vms_eiaf
*eiaf
;
8241 /* Shared libraries. */
8242 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8244 struct alpha_vms_shlib_el
*shlib
;
8246 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8248 if (!shlib
->has_fixups
)
8253 if (VEC_COUNT (shlib
->ca
) > 0)
8255 /* Header + entries. */
8257 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8259 if (VEC_COUNT (shlib
->lp
) > 0)
8261 /* Header + entries. */
8263 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8265 if (VEC_COUNT (shlib
->qr
) > 0)
8267 /* Header + entries. */
8269 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8280 /* Finish now if there is no content. */
8281 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8284 /* Add an eicp entry for the fixup itself. */
8286 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8288 /* This isect could be made RO or EXE after relocations are applied. */
8289 if ((sec
->flags
& SEC_RELOC
) != 0
8290 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8293 chgprt_sz
= 4 + chgprt_num
* sizeof (struct vms_eicp
);
8295 /* Allocate section content (round-up size) */
8296 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8297 + ca_sz
+ lp_sz
+ qr_sz
+ chgprt_sz
;
8298 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8299 content
= bfd_zalloc (info
->output_bfd
, sz
);
8300 if (content
== NULL
)
8303 sec
= alpha_vms_link_hash (info
)->fixup
;
8304 sec
->contents
= content
;
8307 eiaf
= (struct vms_eiaf
*)content
;
8308 off
= sizeof (struct vms_eiaf
);
8309 bfd_putl32 (0, eiaf
->majorid
);
8310 bfd_putl32 (0, eiaf
->minorid
);
8311 bfd_putl32 (0, eiaf
->iaflink
);
8312 bfd_putl32 (0, eiaf
->fixuplnk
);
8313 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8314 bfd_putl32 (0, eiaf
->flags
);
8315 bfd_putl32 (0, eiaf
->qrelfixoff
);
8316 bfd_putl32 (0, eiaf
->lrelfixoff
);
8317 bfd_putl32 (0, eiaf
->qdotadroff
);
8318 bfd_putl32 (0, eiaf
->ldotadroff
);
8319 bfd_putl32 (0, eiaf
->codeadroff
);
8320 bfd_putl32 (0, eiaf
->lpfixoff
);
8321 bfd_putl32 (0, eiaf
->chgprtoff
);
8322 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8323 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8324 bfd_putl32 (0, eiaf
->shlextra
);
8325 bfd_putl32 (0, eiaf
->permctx
);
8326 bfd_putl32 (0, eiaf
->base_va
);
8327 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8334 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8336 struct alpha_vms_shlib_el
*shlib
;
8337 struct vms_shl
*shl
;
8339 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8341 if (!shlib
->has_fixups
)
8344 /* Renumber shared images. */
8345 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8347 shl
= (struct vms_shl
*)(content
+ off
);
8348 bfd_putl32 (0, shl
->baseva
);
8349 bfd_putl32 (0, shl
->shlptr
);
8350 bfd_putl32 (0, shl
->ident
);
8351 bfd_putl32 (0, shl
->permctx
);
8352 shl
->size
= sizeof (struct vms_shl
);
8353 bfd_putl16 (0, shl
->fill_1
);
8355 bfd_putl32 (0, shl
->icb
);
8356 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8357 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8360 off
+= sizeof (struct vms_shl
);
8366 bfd_putl32 (off
, eiaf
->codeadroff
);
8368 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8370 struct alpha_vms_shlib_el
*shlib
;
8373 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8375 if (VEC_COUNT (shlib
->ca
) == 0)
8378 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8379 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8382 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8384 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8390 bfd_putl32 (0, content
+ off
);
8391 bfd_putl32 (0, content
+ off
+ 4);
8398 bfd_putl32 (off
, eiaf
->lpfixoff
);
8400 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8402 struct alpha_vms_shlib_el
*shlib
;
8405 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8407 if (VEC_COUNT (shlib
->lp
) == 0)
8410 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8411 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8414 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8416 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8422 bfd_putl32 (0, content
+ off
);
8423 bfd_putl32 (0, content
+ off
+ 4);
8430 bfd_putl32 (off
, eiaf
->qdotadroff
);
8432 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8434 struct alpha_vms_shlib_el
*shlib
;
8437 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8439 if (VEC_COUNT (shlib
->qr
) == 0)
8442 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8443 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8446 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8448 struct alpha_vms_vma_ref
*r
;
8449 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8450 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8451 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8456 bfd_putl32 (0, content
+ off
);
8457 bfd_putl32 (0, content
+ off
+ 4);
8462 /* Write the change protection table. */
8463 bfd_putl32 (off
, eiaf
->chgprtoff
);
8464 bfd_putl32 (chgprt_num
, content
+ off
);
8467 for (sec
= info
->output_bfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
8469 struct vms_eicp
*eicp
;
8472 if ((sec
->flags
& SEC_LINKER_CREATED
) != 0 &&
8473 strcmp (sec
->name
, "$FIXUP$") == 0)
8475 else if ((sec
->flags
& SEC_RELOC
) != 0
8476 && (sec
->flags
& (SEC_CODE
| SEC_READONLY
)) != 0)
8481 eicp
= (struct vms_eicp
*)(content
+ off
);
8482 bfd_putl64 (sec
->vma
- t
->base_addr
, eicp
->baseva
);
8483 bfd_putl32 ((sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1),
8485 bfd_putl32 (prot
, eicp
->newprt
);
8486 off
+= sizeof (struct vms_eicp
);
8492 /* Called by bfd_hash_traverse to fill the symbol table.
8493 Return FALSE in case of failure. */
8496 alpha_vms_link_output_symbol (struct bfd_hash_entry
*bh
, void *infov
)
8498 struct bfd_link_hash_entry
*hc
= (struct bfd_link_hash_entry
*) bh
;
8499 struct bfd_link_info
*info
= (struct bfd_link_info
*)infov
;
8500 struct alpha_vms_link_hash_entry
*h
;
8501 struct vms_symbol_entry
*sym
;
8503 if (hc
->type
== bfd_link_hash_warning
)
8506 if (hc
->type
== bfd_link_hash_new
)
8509 h
= (struct alpha_vms_link_hash_entry
*) hc
;
8511 switch (h
->root
.type
)
8513 case bfd_link_hash_undefined
:
8515 case bfd_link_hash_new
:
8516 case bfd_link_hash_warning
:
8518 case bfd_link_hash_undefweak
:
8520 case bfd_link_hash_defined
:
8521 case bfd_link_hash_defweak
:
8523 asection
*sec
= h
->root
.u
.def
.section
;
8525 /* FIXME: this is certainly a symbol from a dynamic library. */
8526 if (bfd_is_abs_section (sec
))
8529 if (sec
->owner
->flags
& DYNAMIC
)
8533 case bfd_link_hash_common
:
8535 case bfd_link_hash_indirect
:
8539 /* Do not write not kept symbols. */
8540 if (info
->strip
== strip_some
8541 && bfd_hash_lookup (info
->keep_hash
, h
->root
.root
.string
,
8542 FALSE
, FALSE
) != NULL
)
8547 /* This symbol doesn't come from a VMS object. So we suppose it is
8549 int len
= strlen (h
->root
.root
.string
);
8551 sym
= (struct vms_symbol_entry
*)bfd_zalloc (info
->output_bfd
,
8552 sizeof (*sym
) + len
);
8556 memcpy (sym
->name
, h
->root
.root
.string
, len
);
8558 sym
->owner
= info
->output_bfd
;
8560 sym
->typ
= EGSD__C_SYMG
;
8562 sym
->flags
= EGSY__V_DEF
| EGSY__V_REL
;
8563 sym
->symbol_vector
= h
->root
.u
.def
.value
;
8564 sym
->section
= h
->root
.u
.def
.section
;
8565 sym
->value
= h
->root
.u
.def
.value
;
8570 if (!add_symbol_entry (info
->output_bfd
, sym
))
8577 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8580 struct bfd_link_order
*p
;
8588 if (info
->relocatable
)
8590 /* FIXME: we do not yet support relocatable link. It is not obvious
8591 how to do it for debug infos. */
8592 (*info
->callbacks
->einfo
)(_("%P: relocatable link is not supported\n"));
8596 bfd_get_outsymbols (abfd
) = NULL
;
8597 bfd_get_symcount (abfd
) = 0;
8599 /* Mark all sections which will be included in the output file. */
8600 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8601 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8602 if (p
->type
== bfd_indirect_link_order
)
8603 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8606 /* Handle all the link order information for the sections. */
8607 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8609 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8610 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8612 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8614 printf (" at 0x%08x - 0x%08x: ",
8615 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8618 case bfd_section_reloc_link_order
:
8619 case bfd_symbol_reloc_link_order
:
8620 printf (" section/symbol reloc\n");
8622 case bfd_indirect_link_order
:
8623 printf (" section %s of %s\n",
8624 p
->u
.indirect
.section
->name
,
8625 p
->u
.indirect
.section
->owner
->filename
);
8627 case bfd_data_link_order
:
8628 printf (" explicit data\n");
8631 printf (" *unknown* type %u\n", p
->type
);
8638 /* Generate the symbol table. */
8639 BFD_ASSERT (PRIV (syms
) == NULL
);
8640 if (info
->strip
!= strip_all
)
8641 bfd_hash_traverse (&info
->hash
->table
, alpha_vms_link_output_symbol
, info
);
8643 /* Find the entry point. */
8644 if (bfd_get_start_address (abfd
) == 0)
8646 bfd
*startbfd
= NULL
;
8648 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8650 /* Consider only VMS object files. */
8651 if (sub
->xvec
!= abfd
->xvec
)
8654 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8656 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8658 if (startbfd
!= NULL
8659 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8661 (*info
->callbacks
->einfo
)
8662 (_("%P: multiple entry points: in modules %B and %B\n"),
8671 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8672 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8675 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8677 bfd_set_start_address
8678 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8682 /* Set transfer addresses. */
8685 struct bfd_link_hash_entry
*h
;
8688 PRIV (transfer_address
[i
++]) = 0xffffffff00000340ULL
; /* SYS$IMGACT */
8689 h
= bfd_link_hash_lookup (info
->hash
, "LIB$INITIALIZE", FALSE
, FALSE
, TRUE
);
8690 if (h
!= NULL
&& h
->type
== bfd_link_hash_defined
)
8691 PRIV (transfer_address
[i
++]) =
8692 alpha_vms_get_sym_value (h
->u
.def
.section
, h
->u
.def
.value
);
8693 PRIV (transfer_address
[i
++]) = bfd_get_start_address (abfd
);
8695 PRIV (transfer_address
[i
++]) = 0;
8698 /* Allocate contents.
8699 Also compute the virtual base address. */
8700 base_addr
= (bfd_vma
)-1;
8702 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8704 if (o
->flags
& SEC_HAS_CONTENTS
)
8706 o
->contents
= bfd_alloc (abfd
, o
->size
);
8707 if (o
->contents
== NULL
)
8710 if (o
->flags
& SEC_LOAD
)
8712 if (o
->vma
< base_addr
)
8714 if (o
->vma
+ o
->size
> last_addr
)
8715 last_addr
= o
->vma
+ o
->size
;
8717 /* Clear the RELOC flags. Currently we don't support incremental
8718 linking. We use the RELOC flag for computing the eicp entries. */
8719 o
->flags
&= ~SEC_RELOC
;
8722 /* Create the fixup section. */
8723 fixupsec
= bfd_make_section_anyway_with_flags
8724 (info
->output_bfd
, "$FIXUP$",
8725 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8726 if (fixupsec
== NULL
)
8728 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
8729 fixupsec
->vma
= last_addr
;
8731 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
8732 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
8734 /* Create the DMT section, if necessary. */
8735 BFD_ASSERT (PRIV (dst_section
) == NULL
);
8736 dst
= bfd_get_section_by_name (abfd
, "$DST$");
8737 if (dst
!= NULL
&& dst
->size
== 0)
8741 PRIV (dst_section
) = dst
;
8742 dmt
= bfd_make_section_anyway_with_flags
8743 (info
->output_bfd
, "$DMT$",
8744 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8751 /* Read all sections from the inputs. */
8752 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8754 if (sub
->flags
& DYNAMIC
)
8756 alpha_vms_create_eisd_for_shared (abfd
, sub
);
8760 if (!alpha_vms_read_sections_content (sub
, info
))
8764 /* Handle all the link order information for the sections.
8765 Note: past this point, it is not possible to create new sections. */
8766 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8768 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8772 case bfd_section_reloc_link_order
:
8773 case bfd_symbol_reloc_link_order
:
8776 case bfd_indirect_link_order
:
8780 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
8787 /* Compute fixups. */
8788 if (!alpha_vms_build_fixups (info
))
8791 /* Compute the DMT. */
8795 unsigned char *contents
= NULL
;
8797 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
8798 for (pass
= 0; pass
< 2; pass
++)
8800 unsigned int off
= 0;
8802 /* For each object file (ie for each module). */
8803 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
8806 struct vms_dmt_header
*dmth
= NULL
;
8807 unsigned int psect_count
;
8809 /* Skip this module if it has no DST. */
8810 sub_dst
= PRIV2 (sub
, dst_section
);
8811 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
8816 /* Write the header. */
8817 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
8818 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
8819 bfd_putl32 (sub_dst
->size
, dmth
->size
);
8822 off
+= sizeof (struct vms_dmt_header
);
8825 /* For each section (ie for each psect). */
8826 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8828 /* Only consider interesting sections. */
8829 if (!(o
->flags
& SEC_ALLOC
))
8831 if (o
->flags
& SEC_LINKER_CREATED
)
8836 /* Write an entry. */
8837 struct vms_dmt_psect
*dmtp
;
8839 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
8840 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
8842 bfd_putl32 (o
->size
, dmtp
->length
);
8845 off
+= sizeof (struct vms_dmt_psect
);
8848 bfd_putl32 (psect_count
, dmth
->psect_count
);
8853 contents
= bfd_zalloc (info
->output_bfd
, off
);
8854 if (contents
== NULL
)
8856 dmt
->contents
= contents
;
8861 BFD_ASSERT (off
== dmt
->size
);
8869 /* Read the contents of a section.
8870 buf points to a buffer of buf_size bytes to be filled with
8871 section data (starting at offset into section) */
8874 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
8875 void *buf
, file_ptr offset
,
8876 bfd_size_type count
)
8880 /* Image are easy. */
8881 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8882 return _bfd_generic_get_section_contents (abfd
, section
,
8883 buf
, offset
, count
);
8886 if (offset
+ count
< count
8887 || offset
+ count
> section
->size
)
8889 bfd_set_error (bfd_error_invalid_operation
);
8893 /* If the section is already in memory, just copy it. */
8894 if (section
->flags
& SEC_IN_MEMORY
)
8896 BFD_ASSERT (section
->contents
!= NULL
);
8897 memcpy (buf
, section
->contents
+ offset
, count
);
8900 if (section
->size
== 0)
8903 /* Alloc in memory and read ETIRs. */
8904 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8906 BFD_ASSERT (sec
->contents
== NULL
);
8908 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
8910 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
8911 if (sec
->contents
== NULL
)
8915 if (!alpha_vms_read_sections_content (abfd
, NULL
))
8917 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8919 sec
->flags
|= SEC_IN_MEMORY
;
8920 memcpy (buf
, section
->contents
+ offset
, count
);
8925 /* Set the format of a file being written. */
8928 alpha_vms_mkobject (bfd
* abfd
)
8930 const bfd_arch_info_type
*arch
;
8932 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
8934 if (!vms_initialize (abfd
))
8937 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
8938 if (PRIV (recwr
.buf
) == NULL
)
8941 arch
= bfd_scan_arch ("alpha");
8945 bfd_set_error (bfd_error_wrong_format
);
8949 abfd
->arch_info
= arch
;
8956 /* Called when the BFD is being closed to do any necessary cleanup. */
8959 vms_close_and_cleanup (bfd
* abfd
)
8961 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
8963 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
8966 if (abfd
->format
== bfd_archive
)
8968 bfd_release (abfd
, abfd
->tdata
.any
);
8969 abfd
->tdata
.any
= NULL
;
8973 if (PRIV (recrd
.buf
) != NULL
)
8974 free (PRIV (recrd
.buf
));
8976 if (PRIV (sections
) != NULL
)
8977 free (PRIV (sections
));
8979 bfd_release (abfd
, abfd
->tdata
.any
);
8980 abfd
->tdata
.any
= NULL
;
8983 if (abfd
->direction
== write_direction
)
8985 /* Last step on VMS is to convert the file to variable record length
8987 if (bfd_cache_close (abfd
) != TRUE
)
8989 if (_bfd_vms_convert_to_var_unix_filename (abfd
->filename
) != TRUE
)
8997 /* Called when a new section is created. */
9000 vms_new_section_hook (bfd
* abfd
, asection
*section
)
9004 vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n",
9005 abfd
, section
->index
, section
->name
));
9007 if (! bfd_set_section_alignment (abfd
, section
, 0))
9010 vms_debug2 ((7, "%d: %s\n", section
->index
, section
->name
));
9012 amt
= sizeof (struct vms_section_data_struct
);
9013 section
->used_by_bfd
= bfd_zalloc (abfd
, amt
);
9014 if (section
->used_by_bfd
== NULL
)
9017 /* Create the section symbol. */
9018 return _bfd_generic_new_section_hook (abfd
, section
);
9021 /* Part 4.5, symbols. */
9023 /* Print symbol to file according to how. how is one of
9024 bfd_print_symbol_name just print the name
9025 bfd_print_symbol_more print more (???)
9026 bfd_print_symbol_all print all we know, which is not much right now :-). */
9029 vms_print_symbol (bfd
* abfd
,
9032 bfd_print_symbol_type how
)
9034 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
9035 abfd
, file
, symbol
, how
));
9039 case bfd_print_symbol_name
:
9040 case bfd_print_symbol_more
:
9041 fprintf ((FILE *)file
," %s", symbol
->name
);
9044 case bfd_print_symbol_all
:
9046 const char *section_name
= symbol
->section
->name
;
9048 bfd_print_symbol_vandf (abfd
, file
, symbol
);
9050 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
9056 /* Return information about symbol in ret.
9058 fill type, value and name
9061 B bss segment symbol
9063 D data segment symbol
9065 t a static function symbol
9066 T text segment symbol
9071 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
9077 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
9079 sec
= symbol
->section
;
9086 else if (bfd_is_com_section (sec
))
9088 else if (bfd_is_abs_section (sec
))
9090 else if (bfd_is_und_section (sec
))
9092 else if (bfd_is_ind_section (sec
))
9094 else if ((symbol
->flags
& BSF_FUNCTION
)
9095 || (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
))
9097 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
9099 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
9104 if (ret
->type
!= 'U')
9105 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
9108 ret
->name
= symbol
->name
;
9111 /* Return TRUE if the given symbol sym in the BFD abfd is
9112 a compiler generated local label, else return FALSE. */
9115 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
9118 return name
[0] == '$';
9121 /* Part 4.7, writing an object file. */
9123 /* Sets the contents of the section section in BFD abfd to the data starting
9124 in memory at LOCATION. The data is written to the output section starting
9125 at offset offset for count bytes.
9127 Normally TRUE is returned, else FALSE. Possible error returns are:
9128 o bfd_error_no_contents - The output section does not have the
9129 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
9130 o and some more too */
9133 _bfd_vms_set_section_contents (bfd
* abfd
,
9135 const void * location
,
9137 bfd_size_type count
)
9139 if (section
->contents
== NULL
)
9141 section
->contents
= bfd_alloc (abfd
, section
->size
);
9142 if (section
->contents
== NULL
)
9145 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
9151 /* Set the architecture and machine type in BFD abfd to arch and mach.
9152 Find the correct pointer to a structure and insert it into the arch_info
9156 alpha_vms_set_arch_mach (bfd
*abfd
,
9157 enum bfd_architecture arch
, unsigned long mach
)
9159 if (arch
!= bfd_arch_alpha
9160 && arch
!= bfd_arch_unknown
)
9163 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
9166 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
9169 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
9170 asection
*sec
, flagword no_flags
, flagword flags
)
9172 vms_section_data (sec
)->no_flags
= no_flags
;
9173 vms_section_data (sec
)->flags
= flags
;
9176 struct vms_private_data_struct
*
9177 bfd_vms_get_data (bfd
*abfd
)
9179 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
9182 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9183 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
9184 #define vms_bfd_copy_link_hash_symbol_type \
9185 _bfd_generic_copy_link_hash_symbol_type
9186 #define vms_bfd_is_group_section bfd_generic_is_group_section
9187 #define vms_bfd_discard_group bfd_generic_discard_group
9188 #define vms_section_already_linked _bfd_generic_section_already_linked
9189 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9190 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
9192 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
9193 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
9194 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
9195 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
9196 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
9197 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
9199 /* Symbols table. */
9200 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
9201 #define alpha_vms_bfd_is_target_special_symbol \
9202 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
9203 #define alpha_vms_print_symbol vms_print_symbol
9204 #define alpha_vms_get_symbol_info vms_get_symbol_info
9205 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
9206 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
9207 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
9208 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
9209 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
9210 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_dst_line
9211 #define _bfd_generic_find_nearest_line_discriminator \
9212 _bfd_vms_find_nearest_line_discriminator
9213 #define alpha_vms_find_line _bfd_nosymbols_find_line
9214 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
9216 /* Generic table. */
9217 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
9218 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
9219 #define alpha_vms_new_section_hook vms_new_section_hook
9220 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
9221 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
9223 #define alpha_vms_bfd_get_relocated_section_contents \
9224 bfd_generic_get_relocated_section_contents
9226 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
9227 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
9228 #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
9229 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
9230 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
9231 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
9232 #define alpha_vms_section_already_linked \
9233 _bfd_generic_section_already_linked
9235 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
9236 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
9237 #define alpha_vms_bfd_copy_link_hash_symbol_type \
9238 _bfd_generic_copy_link_hash_symbol_type
9240 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9242 #define alpha_vms_get_dynamic_symtab_upper_bound \
9243 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9244 #define alpha_vms_canonicalize_dynamic_symtab \
9245 _bfd_nodynamic_canonicalize_dynamic_symtab
9246 #define alpha_vms_get_dynamic_reloc_upper_bound \
9247 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9248 #define alpha_vms_canonicalize_dynamic_reloc \
9249 _bfd_nodynamic_canonicalize_dynamic_reloc
9251 const bfd_target alpha_vms_vec
=
9253 "vms-alpha", /* Name. */
9254 bfd_target_evax_flavour
,
9255 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9256 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9258 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9259 | WP_TEXT
| D_PAGED
), /* Object flags. */
9260 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9261 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9262 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9263 0, /* symbol_leading_char. */
9264 ' ', /* ar_pad_char. */
9265 15, /* ar_max_namelen. */
9266 0, /* match priority. */
9267 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9268 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9269 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9270 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9271 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9272 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9274 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9275 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9276 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9277 _bfd_vms_lib_alpha_mkarchive
, bfd_false
},
9278 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9279 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9281 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9282 BFD_JUMP_TABLE_COPY (vms
),
9283 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9284 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9285 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9286 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9287 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9288 BFD_JUMP_TABLE_LINK (alpha_vms
),
9289 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),