1 /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files.
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 Initial version written by Klaus Kaempf (kkaempf@rmi.de)
6 Major rewrite by Adacore.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
26 o Generation of shared image
27 o Generation of GST in image
28 o Relocation optimizations
50 #include "vms/eihvn.h"
51 #include "vms/eobjrec.h"
62 #include "vms/esdfm.h"
63 #include "vms/esdfv.h"
68 #include "vms/internal.h"
71 #define MIN(a,b) ((a) < (b) ? (a) : (b))
73 /* The r_type field in a reloc is one of the following values. */
74 #define ALPHA_R_IGNORE 0
75 #define ALPHA_R_REFQUAD 1
76 #define ALPHA_R_BRADDR 2
77 #define ALPHA_R_HINT 3
78 #define ALPHA_R_SREL16 4
79 #define ALPHA_R_SREL32 5
80 #define ALPHA_R_SREL64 6
81 #define ALPHA_R_OP_PUSH 7
82 #define ALPHA_R_OP_STORE 8
83 #define ALPHA_R_OP_PSUB 9
84 #define ALPHA_R_OP_PRSHIFT 10
85 #define ALPHA_R_LINKAGE 11
86 #define ALPHA_R_REFLONG 12
87 #define ALPHA_R_CODEADDR 13
88 #define ALPHA_R_NOP 14
89 #define ALPHA_R_BSR 15
90 #define ALPHA_R_LDA 16
91 #define ALPHA_R_BOH 17
93 /* These are used with DST_S_C_LINE_NUM. */
94 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
96 /* These are used with DST_S_C_SOURCE */
98 #define DST_S_B_PCLINE_UNSBYTE 1
99 #define DST_S_W_PCLINE_UNSWORD 1
100 #define DST_S_L_PCLINE_UNSLONG 1
102 #define DST_S_B_MODBEG_NAME 14
103 #define DST_S_L_RTNBEG_ADDRESS 5
104 #define DST_S_B_RTNBEG_NAME 13
105 #define DST_S_L_RTNEND_SIZE 5
107 /* These are used with DST_S_C_SOURCE. */
108 #define DST_S_C_SOURCE_HEADER_SIZE 4
110 #define DST_S_B_SRC_DF_LENGTH 1
111 #define DST_S_W_SRC_DF_FILEID 3
112 #define DST_S_B_SRC_DF_FILENAME 20
113 #define DST_S_B_SRC_UNSBYTE 1
114 #define DST_S_W_SRC_UNSWORD 1
115 #define DST_S_L_SRC_UNSLONG 1
117 /* Debugger symbol definitions. */
119 #define DBG_S_L_DMT_MODBEG 0
120 #define DBG_S_L_DST_SIZE 4
121 #define DBG_S_W_DMT_PSECT_COUNT 8
122 #define DBG_S_C_DMT_HEADER_SIZE 12
124 #define DBG_S_L_DMT_PSECT_START 0
125 #define DBG_S_L_DMT_PSECT_LENGTH 4
126 #define DBG_S_C_DMT_PSECT_SIZE 8
128 /* VMS module header. */
144 #define EMH_DATE_LENGTH 17
146 /* VMS End-Of-Module records (EOM/EEOM). */
150 unsigned int eom_l_total_lps
;
151 unsigned short eom_w_comcod
;
152 bfd_boolean eom_has_transfer
;
153 unsigned char eom_b_tfrflg
;
154 unsigned int eom_l_psindx
;
155 unsigned int eom_l_tfradr
;
158 struct vms_symbol_entry
164 unsigned char data_type
;
165 unsigned short flags
;
167 /* Section and offset/value of the symbol. */
168 unsigned int section
;
171 /* Section and offset/value for the entry point (only for subprg). */
172 unsigned int code_section
;
173 unsigned int code_value
;
175 /* Symbol vector offset. */
176 unsigned int symbol_vector
;
178 /* Length of the name. */
179 unsigned char namelen
;
184 /* Stack value for push/pop commands. */
192 #define STACKSIZE 128
194 /* A minimal decoding of DST compilation units. We only decode
195 what's needed to get to the line number information. */
205 struct srecinfo
*next
;
213 struct lineinfo
*next
;
220 struct funcinfo
*next
;
228 /* Chain the previously read compilation unit. */
231 /* The module name. */
234 /* The start offset and size of debug info in the DST section. */
238 /* The lowest and highest addresses contained in this compilation
239 unit as specified in the compilation unit header. */
243 /* The listing line table. */
244 struct lineinfo
*line_table
;
246 /* The source record table. */
247 struct srecinfo
*srec_table
;
249 /* A list of the functions found in this module. */
250 struct funcinfo
*func_table
;
252 /* Current allocation of file_table. */
253 unsigned int file_table_count
;
255 /* An array of the files making up this module. */
256 struct fileinfo
*file_table
;
259 /* BFD private data for alpha-vms. */
261 struct vms_private_data_struct
263 /* If true, relocs have been read. */
264 bfd_boolean reloc_done
;
266 /* Record input buffer. */
267 struct vms_rec_rd recrd
;
268 struct vms_rec_wr recwr
;
270 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
271 struct eom_struct eom_data
; /* data from EOM/EEOM record */
272 unsigned int section_count
; /* # of sections in following array */
273 asection
**sections
; /* array of GSD/EGSD sections */
275 /* Array of raw symbols. */
276 struct vms_symbol_entry
**syms
;
278 /* Canonicalized symbols. */
281 /* Number of symbols. */
282 unsigned int gsd_sym_count
;
283 /* Size of the syms array. */
284 unsigned int max_sym_count
;
285 /* Number of procedure symbols. */
286 unsigned int norm_sym_count
;
288 /* Stack used to evaluate TIR/ETIR commands. */
289 struct stack_struct
*stack
;
292 /* Content reading. */
293 asection
*image_section
; /* section for image_ptr */
294 file_ptr image_offset
; /* Offset for image_ptr. */
296 struct module
*modules
; /* list of all compilation units */
298 struct dst_info
*dst_info
;
299 asection
*dst_section
;
301 unsigned int dst_ptr_offsets_count
; /* # of offsets in following array */
302 unsigned int *dst_ptr_offsets
; /* array of saved image_ptr offsets */
304 /* Shared library support */
305 bfd_vma symvva
; /* relative virtual address of symbol vector */
307 unsigned char matchctl
;
309 /* Shared library index. This is used for input bfd while linking. */
310 unsigned int shr_index
;
312 /* Used to place structures in the file. */
315 /* Simply linked list of eisd. */
316 struct vms_internal_eisd_map
*eisd_head
;
317 struct vms_internal_eisd_map
*eisd_tail
;
319 /* Simply linked list of eisd for shared libraries. */
320 struct vms_internal_eisd_map
*gbl_eisd_head
;
321 struct vms_internal_eisd_map
*gbl_eisd_tail
;
323 /* linkage index counter used by conditional store commands */
324 int vms_linkage_index
;
326 /* see tc-alpha.c of gas for a description. */
327 int flag_hash_long_names
; /* -+, hash instead of truncate */
328 int flag_show_after_trunc
; /* -H, show hashing/truncation */
331 #define PRIV2(abfd, name) \
332 (((struct vms_private_data_struct *)(abfd)->tdata.any)->name)
333 #define PRIV(name) PRIV2(abfd,name)
336 /* Used to keep extra VMS specific information for a given section.
338 reloc_size holds the size of the relocation stream, note this
339 is very different from the number of relocations as VMS relocations
342 reloc_stream is the actual stream of relocation entries. */
344 struct vms_section_data_struct
346 /* Maximnum number of entries in sec->relocation. */
349 /* Corresponding eisd. Used only while generating executables. */
350 struct vms_internal_eisd_map
*eisd
;
352 /* PSC flags to be clear. */
355 /* PSC flags to be set. */
359 #define vms_section_data(sec) \
360 ((struct vms_section_data_struct *)sec->used_by_bfd)
362 /* To be called from the debugger. */
363 struct vms_private_data_struct
*bfd_vms_get_data (bfd
*abfd
);
365 static int vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
);
366 static bfd_boolean
_bfd_vms_slurp_object_records (bfd
* abfd
);
367 static void alpha_vms_add_fixup_lp (struct bfd_link_info
*, bfd
*, bfd
*);
368 static void alpha_vms_add_fixup_ca (struct bfd_link_info
*, bfd
*, bfd
*);
369 static void alpha_vms_add_fixup_qr (struct bfd_link_info
*, bfd
*, bfd
*,
371 static void alpha_vms_add_lw_reloc (struct bfd_link_info
*info
);
372 static void alpha_vms_add_qw_reloc (struct bfd_link_info
*info
);
373 static void alpha_vms_add_lw_fixup (struct bfd_link_info
*, unsigned int,
383 /* Number of elements in VEC. */
385 #define VEC_COUNT(VEC) ((VEC).nbr_el)
387 /* Get the address of the Nth element. */
389 #define VEC_EL(VEC, TYPE, N) (((TYPE *)((VEC).els))[N])
391 #define VEC_INIT(VEC) \
398 /* Be sure there is room for a new element. */
400 static void vector_grow1 (struct vector_type
*vec
, size_t elsz
);
402 /* Allocate room for a new element and return its address. */
404 #define VEC_APPEND(VEC, TYPE) \
405 (vector_grow1 (&VEC, sizeof (TYPE)), &VEC_EL(VEC, TYPE, (VEC).nbr_el++))
407 /* Append an element. */
409 #define VEC_APPEND_EL(VEC, TYPE, EL) \
410 (*(VEC_APPEND (VEC, TYPE)) = EL)
412 struct alpha_vms_vma_ref
414 bfd_vma vma
; /* Vma in the output. */
415 bfd_vma ref
; /* Reference in the input. */
418 struct alpha_vms_shlib_el
421 bfd_boolean has_fixups
;
423 struct vector_type lp
; /* Vector of bfd_vma. */
424 struct vector_type ca
; /* Vector of bfd_vma. */
425 struct vector_type qr
; /* Vector of struct alpha_vms_vma_ref. */
428 /* Alpha VMS linker hash table. */
430 struct alpha_vms_link_hash_table
432 struct bfd_link_hash_table root
;
434 /* Vector of shared libaries. */
435 struct vector_type shrlibs
;
440 /* Base address. Used by fixups. */
444 #define alpha_vms_link_hash(INFO) \
445 ((struct alpha_vms_link_hash_table *)(INFO->hash))
447 /* Alpha VMS linker hash table entry. */
449 struct alpha_vms_link_hash_entry
451 struct bfd_link_hash_entry root
;
453 /* Pointer to the original vms symbol. */
454 struct vms_symbol_entry
*sym
;
459 /* Read & process EIHD record.
460 Return TRUE on success, FALSE on error. */
463 _bfd_vms_slurp_eihd (bfd
*abfd
, unsigned int *eisd_offset
,
464 unsigned int *eihs_offset
)
466 unsigned int imgtype
, size
;
468 struct vms_eihd
*eihd
= (struct vms_eihd
*)PRIV (recrd
.rec
);
470 vms_debug2 ((8, "_bfd_vms_slurp_eihd\n"));
472 size
= bfd_getl32 (eihd
->size
);
473 imgtype
= bfd_getl32 (eihd
->imgtype
);
475 if (imgtype
== EIHD__K_EXE
|| imgtype
== EIHD__K_LIM
)
476 abfd
->flags
|= EXEC_P
;
478 symvva
= bfd_getl64 (eihd
->symvva
);
481 PRIV (symvva
) = symvva
;
482 abfd
->flags
|= DYNAMIC
;
485 PRIV (ident
) = bfd_getl32 (eihd
->ident
);
486 PRIV (matchctl
) = eihd
->matchctl
;
488 *eisd_offset
= bfd_getl32 (eihd
->isdoff
);
489 *eihs_offset
= bfd_getl32 (eihd
->symdbgoff
);
491 vms_debug2 ((4, "EIHD size %d imgtype %d symvva 0x%lx eisd %d eihs %d\n",
492 size
, imgtype
, (unsigned long)symvva
,
493 *eisd_offset
, *eihs_offset
));
498 /* Read & process EISD record.
499 Return TRUE on success, FALSE on error. */
502 _bfd_vms_slurp_eisd (bfd
*abfd
, unsigned int offset
)
504 int section_count
= 0;
506 vms_debug2 ((8, "_bfd_vms_slurp_eisd\n"));
510 struct vms_eisd
*eisd
;
511 unsigned int rec_size
;
513 unsigned long long vaddr
;
520 eisd
= (struct vms_eisd
*)(PRIV (recrd
.rec
) + offset
);
521 rec_size
= bfd_getl32 (eisd
->eisdsize
);
526 /* Skip to next block if pad. */
527 if (rec_size
== 0xffffffff)
529 offset
= (offset
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
535 size
= bfd_getl32 (eisd
->secsize
);
536 vaddr
= bfd_getl64 (eisd
->virt_addr
);
537 flags
= bfd_getl32 (eisd
->flags
);
538 vbn
= bfd_getl32 (eisd
->vbn
);
540 vms_debug2 ((4, "EISD at 0x%x size 0x%x addr 0x%lx flags 0x%x blk %d\n",
541 offset
, size
, (unsigned long)vaddr
, flags
, vbn
));
543 /* VMS combines psects from .obj files into isects in the .exe. This
544 process doesn't preserve enough information to reliably determine
545 what's in each section without examining the data. This is
546 especially true of DWARF debug sections. */
547 bfd_flags
= SEC_ALLOC
;
549 if (flags
& EISD__M_EXE
)
550 bfd_flags
|= SEC_CODE
| SEC_HAS_CONTENTS
| SEC_LOAD
;
552 if (flags
& EISD__M_NONSHRADR
)
553 bfd_flags
|= SEC_DATA
| SEC_HAS_CONTENTS
| SEC_LOAD
;
555 if (!(flags
& EISD__M_WRT
))
556 bfd_flags
|= SEC_READONLY
;
558 if (flags
& EISD__M_DZRO
)
559 bfd_flags
|= SEC_DATA
;
561 if (flags
& EISD__M_FIXUPVEC
)
562 bfd_flags
|= SEC_DATA
| SEC_HAS_CONTENTS
| SEC_LOAD
;
564 if (flags
& EISD__M_CRF
)
565 bfd_flags
|= SEC_HAS_CONTENTS
| SEC_LOAD
;
567 if (flags
& EISD__M_GBL
)
569 name
= _bfd_vms_save_counted_string (eisd
->gblnam
);
570 bfd_flags
|= SEC_COFF_SHARED_LIBRARY
;
571 bfd_flags
&= ~(SEC_ALLOC
| SEC_LOAD
);
573 else if (flags
& EISD__M_FIXUPVEC
)
575 else if (eisd
->type
== EISD__K_USRSTACK
)
581 name
= (char*) bfd_alloc (abfd
, 32);
582 if (flags
& EISD__M_DZRO
)
584 else if (flags
& EISD__M_EXE
)
586 else if (!(flags
& EISD__M_WRT
))
590 BFD_ASSERT (section_count
< 999);
591 sprintf (name
, "$%s_%03d$", pfx
, section_count
++);
594 section
= bfd_make_section (abfd
, name
);
599 section
->filepos
= vbn
? VMS_BLOCK_SIZE
* (vbn
- 1) : 0;
600 section
->size
= size
;
601 section
->vma
= vaddr
;
603 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
610 /* Read & process EIHS record.
611 Return TRUE on success, FALSE on error. */
614 _bfd_vms_slurp_eihs (bfd
*abfd
, unsigned int offset
)
616 unsigned char *p
= PRIV (recrd
.rec
) + offset
;
617 unsigned int gstvbn
= bfd_getl32 (p
+ EIHS__L_GSTVBN
);
618 unsigned int gstsize ATTRIBUTE_UNUSED
= bfd_getl32 (p
+ EIHS__L_GSTSIZE
);
619 unsigned int dstvbn
= bfd_getl32 (p
+ EIHS__L_DSTVBN
);
620 unsigned int dstsize
= bfd_getl32 (p
+ EIHS__L_DSTSIZE
);
621 unsigned int dmtvbn
= bfd_getl32 (p
+ EIHS__L_DMTVBN
);
622 unsigned int dmtbytes
= bfd_getl32 (p
+ EIHS__L_DMTBYTES
);
626 vms_debug (8, "_bfd_vms_slurp_ihs\n");
627 vms_debug (4, "EIHS record gstvbn %d gstsize %d dstvbn %d dstsize %d dmtvbn %d dmtbytes %d\n",
628 gstvbn
, gstsize
, dstvbn
, dstsize
, dmtvbn
, dmtbytes
);
633 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
635 section
= bfd_make_section (abfd
, "$DST$");
639 section
->size
= dstsize
;
640 section
->filepos
= VMS_BLOCK_SIZE
* (dstvbn
- 1);
642 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
645 PRIV (dst_section
) = section
;
646 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
651 flagword bfd_flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
;
653 section
= bfd_make_section (abfd
, "$DMT$");
657 section
->size
= dmtbytes
;
658 section
->filepos
= VMS_BLOCK_SIZE
* (dmtvbn
- 1);
660 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
666 flagword bfd_flags
= SEC_HAS_CONTENTS
;
668 section
= bfd_make_section (abfd
, "$GST$");
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 section
->filepos
= VMS_BLOCK_SIZE
* (gstvbn
- 1);
682 section
->size
= bfd_tell (abfd
) - section
->filepos
;
684 if (!bfd_set_section_flags (abfd
, section
, bfd_flags
))
687 abfd
->flags
|= HAS_SYMS
;
693 /* Object file reading. */
695 /* Object file input functions. */
697 /* Get next record from object file to vms_buf.
698 Set PRIV(buf_size) and return it
700 This is a little tricky since it should be portable.
702 The openVMS object file has 'variable length' which means that
703 read() returns data in chunks of (hopefully) correct and expected
704 size. The linker (and other tools on VMS) depend on that. Unix
705 doesn't know about 'formatted' files, so reading and writing such
706 an object file in a Unix environment is not trivial.
708 With the tool 'file' (available on all VMS FTP sites), one
709 can view and change the attributes of a file. Changing from
710 'variable length' to 'fixed length, 512 bytes' reveals the
711 record size at the first 2 bytes of every record. The same
712 may happen during the transfer of object files from VMS to Unix,
713 at least with UCX, the DEC implementation of TCP/IP.
715 The VMS format repeats the size at bytes 2 & 3 of every record.
717 On the first call (file_format == FF_UNKNOWN) we check if
718 the first and the third byte pair (!) of the record match.
719 If they do it's an object file in an Unix environment or with
720 wrong attributes (FF_FOREIGN), else we should be in a VMS
721 environment where read() returns the record size (FF_NATIVE).
723 Reading is always done in 2 steps:
724 1. first just the record header is read and the size extracted,
725 2. then the read buffer is adjusted and the remaining bytes are
728 All file I/O is done on even file positions. */
730 #define VMS_OBJECT_ADJUSTMENT 2
733 maybe_adjust_record_pointer_for_object (bfd
*abfd
)
735 /* Set the file format once for all on the first invocation. */
736 if (PRIV (recrd
.file_format
) == FF_UNKNOWN
)
738 if (PRIV (recrd
.rec
)[0] == PRIV (recrd
.rec
)[4]
739 && PRIV (recrd
.rec
)[1] == PRIV (recrd
.rec
)[5])
740 PRIV (recrd
.file_format
) = FF_FOREIGN
;
742 PRIV (recrd
.file_format
) = FF_NATIVE
;
745 /* The adjustment is needed only in an Unix environment. */
746 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
747 PRIV (recrd
.rec
) += VMS_OBJECT_ADJUSTMENT
;
750 /* Implement step #1 of the object record reading procedure.
751 Return the record type or -1 on failure. */
754 _bfd_vms_get_object_record (bfd
*abfd
)
756 unsigned int test_len
= 6;
759 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
761 /* Skip alignment byte if the current position is odd. */
762 if (PRIV (recrd
.file_format
) == FF_FOREIGN
&& (bfd_tell (abfd
) & 1))
764 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
766 bfd_set_error (bfd_error_file_truncated
);
771 /* Read the record header */
772 if (bfd_bread (PRIV (recrd
.buf
), test_len
, abfd
) != test_len
)
774 bfd_set_error (bfd_error_file_truncated
);
778 /* Reset the record pointer. */
779 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
780 maybe_adjust_record_pointer_for_object (abfd
);
782 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
785 type
= bfd_getl16 (PRIV (recrd
.rec
));
787 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
788 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
793 /* Implement step #2 of the object record reading procedure.
794 Return the size of the record or 0 on failure. */
797 vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
)
799 unsigned int to_read
;
801 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
803 /* Extract record size. */
804 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
806 if (PRIV (recrd
.rec_size
) <= 0)
808 bfd_set_error (bfd_error_file_truncated
);
812 /* That's what the linker manual says. */
813 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
815 bfd_set_error (bfd_error_file_truncated
);
819 /* Take into account object adjustment. */
820 to_read
= PRIV (recrd
.rec_size
);
821 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
822 to_read
+= VMS_OBJECT_ADJUSTMENT
;
824 /* Adjust the buffer. */
825 if (to_read
> PRIV (recrd
.buf_size
))
828 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
829 if (PRIV (recrd
.buf
) == NULL
)
831 PRIV (recrd
.buf_size
) = to_read
;
834 /* Read the remaining record. */
835 to_read
-= read_so_far
;
837 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
839 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
841 bfd_set_error (bfd_error_file_truncated
);
845 /* Reset the record pointer. */
846 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
847 maybe_adjust_record_pointer_for_object (abfd
);
849 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
850 PRIV (recrd
.rec_size
)));
852 return PRIV (recrd
.rec_size
);
855 /* Read and process emh record.
856 Return TRUE on success, FALSE on error. */
859 _bfd_vms_slurp_ehdr (bfd
*abfd
)
862 unsigned char *vms_rec
;
865 vms_rec
= PRIV (recrd
.rec
);
867 vms_debug2 ((2, "HDR/EMH\n"));
869 subtype
= bfd_getl16 (vms_rec
+ 4);
871 vms_debug2 ((3, "subtype %d\n", subtype
));
877 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
878 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
879 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
880 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
881 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20);
882 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
883 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
);
885 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
889 PRIV (hdr_data
).hdr_c_lnm
=
890 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
894 PRIV (hdr_data
).hdr_c_src
=
895 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
899 PRIV (hdr_data
).hdr_c_ttl
=
900 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
909 bfd_set_error (bfd_error_wrong_format
);
916 /* Typical sections for evax object files. */
918 #define EVAX_ABS_NAME "$ABS$"
919 #define EVAX_CODE_NAME "$CODE$"
920 #define EVAX_LINK_NAME "$LINK$"
921 #define EVAX_DATA_NAME "$DATA$"
922 #define EVAX_BSS_NAME "$BSS$"
923 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
924 #define EVAX_READONLY_NAME "$READONLY$"
925 #define EVAX_LITERAL_NAME "$LITERAL$"
926 #define EVAX_LITERALS_NAME "$LITERALS"
927 #define EVAX_COMMON_NAME "$COMMON$"
928 #define EVAX_LOCAL_NAME "$LOCAL$"
930 struct sec_flags_struct
932 const char *name
; /* Name of section. */
934 flagword flags_always
; /* Flags we set always. */
936 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
939 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
941 static struct sec_flags_struct evax_section_flags
[] =
947 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
949 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
),
951 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
),
952 (SEC_CODE
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
954 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
),
955 (SEC_DATA
| SEC_READONLY
),
956 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
),
957 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
959 (EGPS__V_REL
| EGPS__V_RD
),
960 (SEC_DATA
| SEC_READONLY
),
961 (EGPS__V_REL
| EGPS__V_RD
),
962 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
964 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
966 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
967 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
969 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
971 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
973 { EVAX_READONLYADDR_NAME
,
974 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
),
975 (SEC_DATA
| SEC_READONLY
),
976 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
),
977 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
978 { EVAX_READONLY_NAME
,
979 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
),
980 (SEC_DATA
| SEC_READONLY
),
981 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
),
982 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
984 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
986 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
987 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
988 { EVAX_LITERALS_NAME
,
989 (EGPS__V_PIC
| EGPS__V_OVR
),
990 (SEC_DATA
| SEC_READONLY
),
991 (EGPS__V_PIC
| EGPS__V_OVR
),
992 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
994 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
996 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
997 (SEC_IN_MEMORY
| SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) }
1000 /* Retrieve bfd section flags by name and size. */
1003 vms_secflag_by_name (bfd
*abfd ATTRIBUTE_UNUSED
,
1004 struct sec_flags_struct
*section_flags
,
1010 while (section_flags
[i
].name
!= NULL
)
1012 if (strcmp (name
, section_flags
[i
].name
) == 0)
1015 return section_flags
[i
].flags_hassize
;
1017 return section_flags
[i
].flags_always
;
1022 return section_flags
[i
].flags_hassize
;
1023 return section_flags
[i
].flags_always
;
1026 /* Retrieve vms section flags by name and size. */
1029 vms_esecflag_by_name (struct sec_flags_struct
*section_flags
,
1035 while (section_flags
[i
].name
!= NULL
)
1037 if (strcmp (name
, section_flags
[i
].name
) == 0)
1040 return section_flags
[i
].vflags_hassize
;
1042 return section_flags
[i
].vflags_always
;
1047 return section_flags
[i
].vflags_hassize
;
1048 return section_flags
[i
].vflags_always
;
1051 /* Input routines. */
1053 static struct vms_symbol_entry
*
1054 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1056 struct vms_symbol_entry
*entry
;
1060 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1063 entry
->namelen
= len
;
1064 memcpy (entry
->name
, ascic
, len
);
1065 entry
->name
[len
] = 0;
1066 entry
->owner
= abfd
;
1068 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1070 if (PRIV (max_sym_count
) == 0)
1072 PRIV (max_sym_count
) = 128;
1073 PRIV (syms
) = bfd_malloc
1074 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1078 PRIV (max_sym_count
) *= 2;
1079 PRIV (syms
) = bfd_realloc
1081 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1083 if (PRIV (syms
) == NULL
)
1087 PRIV (syms
)[PRIV (gsd_sym_count
)++] = entry
;
1091 /* Read and process EGSD. Return FALSE on failure. */
1094 _bfd_vms_slurp_egsd (bfd
* abfd
)
1096 int gsd_type
, gsd_size
;
1098 unsigned char *vms_rec
;
1099 flagword new_flags
, old_flags
;
1101 unsigned long base_addr
;
1102 unsigned long align_addr
;
1104 vms_debug2 ((2, "EGSD\n"));
1106 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1107 PRIV (recrd
.rec_size
) -= 8;
1109 /* Calculate base address for each section. */
1112 while (PRIV (recrd
.rec_size
) > 0)
1114 vms_rec
= PRIV (recrd
.rec
);
1116 gsd_type
= bfd_getl16 (vms_rec
);
1117 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1119 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1125 /* Program section definition. */
1126 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1127 name
= _bfd_vms_save_counted_string (&egps
->namlng
);
1128 section
= bfd_make_section (abfd
, name
);
1131 old_flags
= bfd_getl16 (egps
->flags
);
1132 vms_section_data (section
)->flags
= old_flags
;
1133 vms_section_data (section
)->no_flags
= 0;
1134 section
->size
= bfd_getl32 (egps
->alloc
);
1135 new_flags
= vms_secflag_by_name (abfd
, evax_section_flags
, name
,
1137 if (!(old_flags
& EGPS__V_NOMOD
))
1139 new_flags
|= SEC_HAS_CONTENTS
;
1140 if (old_flags
& EGPS__V_REL
)
1141 new_flags
|= SEC_RELOC
;
1143 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1145 section
->alignment_power
= egps
->align
;
1146 align_addr
= (1 << section
->alignment_power
);
1147 if ((base_addr
% align_addr
) != 0)
1148 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1149 section
->vma
= (bfd_vma
)base_addr
;
1150 base_addr
+= section
->size
;
1151 section
->filepos
= (unsigned int)-1;
1153 vms_debug (4, "EGSD P-section %d (%s, flags %04x) ",
1154 section
->index
, name
, old_flags
);
1155 vms_debug (4, "%lu bytes at 0x%08lx (mem %p)\n",
1156 (unsigned long)section
->size
,
1157 (unsigned long)section
->vma
, section
->contents
);
1165 struct vms_symbol_entry
*entry
;
1166 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1168 old_flags
= bfd_getl16 (egsy
->flags
);
1169 if (old_flags
& EGSY__V_DEF
)
1170 nameoff
= ESDF__B_NAMLNG
;
1172 nameoff
= ESRF__B_NAMLNG
;
1174 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1178 /* Allow only duplicate reference. */
1179 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1182 if (entry
->typ
== 0)
1184 entry
->typ
= gsd_type
;
1185 entry
->data_type
= egsy
->datyp
;
1186 entry
->flags
= old_flags
;
1189 if (old_flags
& EGSY__V_DEF
)
1191 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1193 entry
->value
= bfd_getl64 (esdf
->value
);
1194 entry
->section
= bfd_getl32 (esdf
->psindx
);
1196 if (old_flags
& EGSY__V_NORM
)
1198 PRIV (norm_sym_count
)++;
1200 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1201 entry
->code_section
= bfd_getl32 (esdf
->ca_psindx
);
1210 struct vms_symbol_entry
*entry
;
1211 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1213 old_flags
= bfd_getl16 (egst
->header
.flags
);
1214 if (old_flags
& EGSY__V_DEF
)
1215 nameoff
= ESDF__B_NAMLNG
;
1217 nameoff
= ESRF__B_NAMLNG
;
1219 entry
= add_symbol (abfd
, &egst
->namlng
);
1224 entry
->typ
= gsd_type
;
1225 entry
->data_type
= egst
->header
.datyp
;
1226 entry
->flags
= old_flags
;
1228 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1230 entry
->section
= bfd_getl32 (egst
->psindx
);
1231 entry
->value
= bfd_getl64 (egst
->lp_2
);
1233 if (old_flags
& EGSY__V_NORM
)
1235 PRIV (norm_sym_count
)++;
1237 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1238 entry
->code_section
= 0;
1247 (*_bfd_error_handler
) (_("Unknown EGSD subtype %d"), gsd_type
);
1248 bfd_set_error (bfd_error_bad_value
);
1252 PRIV (recrd
.rec_size
) -= gsd_size
;
1253 PRIV (recrd
.rec
) += gsd_size
;
1256 if (PRIV (gsd_sym_count
) > 0)
1257 abfd
->flags
|= HAS_SYMS
;
1262 /* Stack routines for vms ETIR commands. */
1264 /* Push value and section index. */
1267 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1269 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1270 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1272 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1273 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1275 if (PRIV (stackptr
) >= STACKSIZE
)
1277 bfd_set_error (bfd_error_bad_value
);
1278 (*_bfd_error_handler
) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1283 /* Pop value and section index. */
1286 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1288 if (PRIV (stackptr
) == 0)
1290 bfd_set_error (bfd_error_bad_value
);
1291 (*_bfd_error_handler
) (_("Stack underflow in _bfd_vms_pop"));
1295 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1296 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1298 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1301 /* Routines to fill sections contents during tir/etir read. */
1303 /* Initialize image buffer pointer to be filled. */
1306 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1310 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1312 sec
= PRIV (sections
)[sect
];
1316 /* Reading contents to an output bfd. */
1318 if (sec
->output_section
== NULL
)
1320 /* Section discarded. */
1321 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1323 /* This is not used. */
1324 PRIV (image_section
) = NULL
;
1325 PRIV (image_offset
) = 0;
1328 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1329 PRIV (image_section
) = sec
->output_section
;
1333 PRIV (image_offset
) = vma
;
1334 PRIV (image_section
) = sec
;
1338 /* Increment image buffer pointer by offset. */
1341 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1343 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1345 PRIV (image_offset
) += offset
;
1348 /* Save current DST location counter under specified index. */
1351 dst_define_location (bfd
*abfd
, unsigned int loc
)
1353 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1355 /* Grow the ptr offset table if necessary. */
1356 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1358 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1359 (loc
+ 1) * sizeof (unsigned int));
1360 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1363 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1366 /* Restore saved DST location counter from specified index. */
1369 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1371 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1373 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1376 /* Retrieve saved DST location counter from specified index. */
1379 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1381 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1383 return PRIV (dst_ptr_offsets
)[loc
];
1386 /* Write multiple bytes to section image. */
1389 image_write (bfd
*abfd
, unsigned char *ptr
, int size
)
1392 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1393 (long)PRIV (image_offset
));
1394 _bfd_hexdump (9, ptr
, size
, 0);
1397 if (PRIV (image_section
)->contents
!= NULL
)
1399 asection
*sec
= PRIV (image_section
);
1400 file_ptr off
= PRIV (image_offset
);
1403 if (off
> (file_ptr
)sec
->size
1404 || size
> (file_ptr
)sec
->size
1405 || off
+ size
> (file_ptr
)sec
->size
)
1407 bfd_set_error (bfd_error_bad_value
);
1411 memcpy (sec
->contents
+ off
, ptr
, size
);
1414 PRIV (image_offset
) += size
;
1418 /* Write byte to section image. */
1421 image_write_b (bfd
* abfd
, unsigned int value
)
1423 unsigned char data
[1];
1425 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1429 return image_write (abfd
, data
, sizeof (data
));
1432 /* Write 2-byte word to image. */
1435 image_write_w (bfd
* abfd
, unsigned int value
)
1437 unsigned char data
[2];
1439 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1441 bfd_putl16 (value
, data
);
1442 return image_write (abfd
, data
, sizeof (data
));
1445 /* Write 4-byte long to image. */
1448 image_write_l (bfd
* abfd
, unsigned long value
)
1450 unsigned char data
[4];
1452 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1454 bfd_putl32 (value
, data
);
1455 return image_write (abfd
, data
, sizeof (data
));
1458 /* Write 8-byte quad to image. */
1461 image_write_q (bfd
* abfd
, bfd_vma value
)
1463 unsigned char data
[8];
1465 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1467 bfd_putl64 (value
, data
);
1468 return image_write (abfd
, data
, sizeof (data
));
1472 _bfd_vms_etir_name (int cmd
)
1476 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1477 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1478 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1479 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1480 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1481 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1482 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1483 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1484 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1485 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1486 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1487 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1488 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1489 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1490 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1491 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1492 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1493 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1494 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1495 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1496 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1497 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1498 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1499 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1500 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1501 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1502 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1503 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1504 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1505 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1506 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1507 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1508 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1509 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1510 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1511 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1512 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1513 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1514 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1515 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1516 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1517 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1518 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1519 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1520 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1521 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1522 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1523 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1524 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1527 /* These names have not yet been added to this switch statement. */
1528 (*_bfd_error_handler
) (_("unknown ETIR command %d"), cmd
);
1533 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1536 _bfd_vms_get_value (bfd
*abfd
, const unsigned char *ascic
,
1537 struct bfd_link_info
*info
,
1539 struct alpha_vms_link_hash_entry
**hp
)
1544 struct alpha_vms_link_hash_entry
*h
;
1546 /* Not linking. Do not try to resolve the symbol. */
1555 for (i
= 0; i
< len
; i
++)
1556 name
[i
] = ascic
[i
+ 1];
1559 h
= (struct alpha_vms_link_hash_entry
*)
1560 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1565 && (h
->root
.type
== bfd_link_hash_defined
1566 || h
->root
.type
== bfd_link_hash_defweak
))
1567 *vma
= h
->root
.u
.def
.value
1568 + h
->root
.u
.def
.section
->output_offset
1569 + h
->root
.u
.def
.section
->output_section
->vma
;
1570 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1574 if (!(*info
->callbacks
->undefined_symbol
)
1575 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
))
1583 #define RELC_SHR_BASE 0x10000
1584 #define RELC_SEC_BASE 0x20000
1585 #define RELC_MASK 0x0ffff
1588 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1590 /* Handle undefined symbols. */
1591 if (h
== NULL
|| h
->sym
== NULL
)
1594 if (h
->sym
->typ
== EGSD__C_SYMG
)
1596 if (h
->sym
->flags
& EGSY__V_REL
)
1597 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1600 /* Can this happen ? I'd like to see an example. */
1604 if (h
->sym
->typ
== EGSD__C_SYM
)
1606 if (h
->sym
->flags
& EGSY__V_REL
)
1615 alpha_vms_get_sym_value (unsigned int sect
, bfd_vma addr
,
1616 struct alpha_vms_link_hash_entry
*h
)
1620 BFD_ASSERT (h
&& (h
->root
.type
== bfd_link_hash_defined
1621 || h
->root
.type
== bfd_link_hash_defweak
));
1623 s
= PRIV2 (h
->root
.u
.def
.section
->owner
, sections
)[sect
];
1624 return s
->output_section
->vma
+ s
->output_offset
+ addr
;
1628 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1629 unsigned int rel
, bfd_vma vma
)
1631 asection
*sec
= PRIV (sections
)[rel
& RELC_MASK
];
1635 if (sec
->output_section
== NULL
)
1637 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1640 return vma
+ sec
->vma
;
1643 /* Read an ETIR record from ABFD. If INFO is not null, put the content into
1644 the output section (used during linking).
1645 Return FALSE in case of error. */
1648 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1651 unsigned int length
;
1652 unsigned char *maxptr
;
1657 struct alpha_vms_link_hash_entry
*h
;
1659 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1660 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1662 ptr
= PRIV (recrd
.rec
);
1663 length
= PRIV (recrd
.rec_size
);
1664 maxptr
= ptr
+ length
;
1666 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1668 while (ptr
< maxptr
)
1670 int cmd
= bfd_getl16 (ptr
);
1671 int cmd_length
= bfd_getl16 (ptr
+ 2);
1676 _bfd_vms_debug (4, "etir: %s(%d)\n",
1677 _bfd_vms_etir_name (cmd
), cmd
);
1678 _bfd_hexdump (8, ptr
, cmd_length
- 4, (long) ptr
);
1686 stack 32 bit value of symbol (high bits set to 0). */
1687 case ETIR__C_STA_GBL
:
1688 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1689 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1695 stack 32 bit value, sign extend to 64 bit. */
1696 case ETIR__C_STA_LW
:
1697 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1703 stack 64 bit value of symbol. */
1704 case ETIR__C_STA_QW
:
1705 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1708 /* Stack psect base plus quadword offset
1709 arg: lw section index
1710 qw signed quadword offset (low 32 bits)
1712 Stack qw argument and section index
1713 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1714 case ETIR__C_STA_PQ
:
1718 psect
= bfd_getl32 (ptr
);
1719 if ((unsigned int) psect
>= PRIV (section_count
))
1721 (*_bfd_error_handler
) (_("bad section index in %s"),
1722 _bfd_vms_etir_name (cmd
));
1723 bfd_set_error (bfd_error_bad_value
);
1726 op1
= bfd_getl64 (ptr
+ 4);
1727 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1731 case ETIR__C_STA_LI
:
1732 case ETIR__C_STA_MOD
:
1733 case ETIR__C_STA_CKARG
:
1734 (*_bfd_error_handler
) (_("unsupported STA cmd %s"),
1735 _bfd_vms_etir_name (cmd
));
1739 /* Store byte: pop stack, write byte
1742 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1743 if (rel1
!= RELC_NONE
)
1745 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1748 /* Store word: pop stack, write word
1751 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1752 if (rel1
!= RELC_NONE
)
1754 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1757 /* Store longword: pop stack, write longword
1759 case ETIR__C_STO_LW
:
1760 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1761 if (rel1
& RELC_SEC_BASE
)
1763 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1766 else if (rel1
& RELC_SHR_BASE
)
1768 alpha_vms_add_lw_fixup (info
, rel1
& RELC_MASK
, op1
);
1771 if (rel1
!= RELC_NONE
)
1773 if (rel1
!= RELC_REL
)
1775 alpha_vms_add_lw_reloc (info
);
1777 image_write_l (abfd
, op1
);
1780 /* Store quadword: pop stack, write quadword
1782 case ETIR__C_STO_QW
:
1783 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1784 if (rel1
& RELC_SEC_BASE
)
1786 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1789 else if (rel1
& RELC_SHR_BASE
)
1791 if (rel1
!= RELC_NONE
)
1793 if (rel1
!= RELC_REL
)
1795 alpha_vms_add_qw_reloc (info
);
1797 image_write_q (abfd
, op1
);
1800 /* Store immediate repeated: pop stack for repeat count
1803 case ETIR__C_STO_IMMR
:
1807 size
= bfd_getl32 (ptr
);
1808 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1809 if (rel1
!= RELC_NONE
)
1812 image_write (abfd
, ptr
+ 4, size
);
1816 /* Store global: write symbol value
1817 arg: cs global symbol name. */
1818 case ETIR__C_STO_GBL
:
1819 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1822 if (h
->sym
->typ
== EGSD__C_SYMG
)
1824 alpha_vms_add_fixup_qr
1825 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
1830 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
1832 alpha_vms_add_qw_reloc (info
);
1835 image_write_q (abfd
, op1
);
1838 /* Store code address: write address of entry point
1839 arg: cs global symbol name (procedure). */
1840 case ETIR__C_STO_CA
:
1841 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1844 if (h
->sym
->flags
& EGSY__V_NORM
)
1846 /* That's really a procedure. */
1847 if (h
->sym
->typ
== EGSD__C_SYMG
)
1849 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
1850 op1
= h
->sym
->symbol_vector
;
1854 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1855 h
->sym
->code_value
, h
);
1856 alpha_vms_add_qw_reloc (info
);
1861 /* Symbol is not a procedure. */
1865 image_write_q (abfd
, op1
);
1868 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1870 case ETIR__C_STO_OFF
:
1871 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1873 if (!(rel1
& RELC_SEC_BASE
))
1876 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1878 image_write_q (abfd
, op1
);
1882 arg: lw count of bytes
1884 case ETIR__C_STO_IMM
:
1888 size
= bfd_getl32 (ptr
);
1889 image_write (abfd
, ptr
+ 4, size
);
1893 /* This code is 'reserved to digital' according to the openVMS
1894 linker manual, however it is generated by the DEC C compiler
1895 and defined in the include file.
1896 FIXME, since the following is just a guess
1897 store global longword: store 32bit value of symbol
1898 arg: cs symbol name. */
1899 case ETIR__C_STO_GBL_LW
:
1900 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1904 image_write_l (abfd
, op1
);
1907 case ETIR__C_STO_RB
:
1908 case ETIR__C_STO_AB
:
1909 case ETIR__C_STO_LP_PSB
:
1910 (*_bfd_error_handler
) (_("%s: not supported"),
1911 _bfd_vms_etir_name (cmd
));
1914 case ETIR__C_STO_HINT_GBL
:
1915 case ETIR__C_STO_HINT_PS
:
1916 (*_bfd_error_handler
) (_("%s: not implemented"),
1917 _bfd_vms_etir_name (cmd
));
1921 /* 200 Store-conditional Linkage Pair
1923 case ETIR__C_STC_LP
:
1925 /* 202 Store-conditional Address at global address
1929 case ETIR__C_STC_GBL
:
1931 /* 203 Store-conditional Code Address at global address
1933 cs procedure name. */
1934 case ETIR__C_STC_GCA
:
1936 /* 204 Store-conditional Address at psect + offset
1940 case ETIR__C_STC_PS
:
1941 (*_bfd_error_handler
) (_("%s: not supported"),
1942 _bfd_vms_etir_name (cmd
));
1946 /* 201 Store-conditional Linkage Pair with Procedure Signature
1952 case ETIR__C_STC_LP_PSB
:
1953 _bfd_vms_get_value (abfd
, ptr
+ 4, info
, &op1
, &h
);
1956 if (h
->sym
->typ
== EGSD__C_SYMG
)
1958 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
1959 op1
= h
->sym
->symbol_vector
;
1964 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1965 h
->sym
->code_value
, h
);
1966 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
1972 /* Undefined symbol. */
1976 image_write_q (abfd
, op1
);
1977 image_write_q (abfd
, op2
);
1980 /* 205 Store-conditional NOP at address of global
1982 case ETIR__C_STC_NOP_GBL
:
1985 /* 207 Store-conditional BSR at global address
1988 case ETIR__C_STC_BSR_GBL
:
1991 /* 209 Store-conditional LDA at global address
1994 case ETIR__C_STC_LDA_GBL
:
1997 /* 211 Store-conditional BSR or Hint at global address
2000 case ETIR__C_STC_BOH_GBL
:
2001 /* Currentl ignored. */
2004 /* 213 Store-conditional NOP,BSR or HINT at global address
2007 case ETIR__C_STC_NBH_GBL
:
2009 /* 206 Store-conditional NOP at pect + offset
2012 case ETIR__C_STC_NOP_PS
:
2014 /* 208 Store-conditional BSR at pect + offset
2017 case ETIR__C_STC_BSR_PS
:
2019 /* 210 Store-conditional LDA at psect + offset
2022 case ETIR__C_STC_LDA_PS
:
2024 /* 212 Store-conditional BSR or Hint at pect + offset
2027 case ETIR__C_STC_BOH_PS
:
2029 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2031 case ETIR__C_STC_NBH_PS
:
2032 (*_bfd_error_handler
) ("%s: not supported",
2033 _bfd_vms_etir_name (cmd
));
2037 /* Det relocation base: pop stack, set image location counter
2039 case ETIR__C_CTL_SETRB
:
2040 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2041 if (!(rel1
& RELC_SEC_BASE
))
2043 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2046 /* Augment relocation base: increment image location counter by offset
2047 arg: lw offset value. */
2048 case ETIR__C_CTL_AUGRB
:
2049 op1
= bfd_getl32 (ptr
);
2050 image_inc_ptr (abfd
, op1
);
2053 /* Define location: pop index, save location counter under index
2055 case ETIR__C_CTL_DFLOC
:
2056 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2057 if (rel1
!= RELC_NONE
)
2059 dst_define_location (abfd
, op1
);
2062 /* Set location: pop index, restore location counter from index
2064 case ETIR__C_CTL_STLOC
:
2065 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2066 if (rel1
!= RELC_NONE
)
2068 dst_restore_location (abfd
, op1
);
2071 /* Stack defined location: pop index, push location counter from index
2073 case ETIR__C_CTL_STKDL
:
2074 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2075 if (rel1
!= RELC_NONE
)
2077 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2080 case ETIR__C_OPR_NOP
: /* No-op. */
2083 case ETIR__C_OPR_ADD
: /* Add. */
2084 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2085 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2086 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2088 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2090 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2093 case ETIR__C_OPR_SUB
: /* Subtract. */
2094 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2095 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2096 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2098 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2100 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2101 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2104 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2106 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2109 case ETIR__C_OPR_MUL
: /* Multiply. */
2110 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2111 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2112 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2114 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2117 case ETIR__C_OPR_DIV
: /* Divide. */
2118 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2119 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2120 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2123 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2125 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2128 case ETIR__C_OPR_AND
: /* Logical AND. */
2129 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2130 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2131 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2133 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2136 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2137 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2138 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2139 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2141 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2144 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2145 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2146 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2147 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2149 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2152 case ETIR__C_OPR_NEG
: /* Negate. */
2153 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2154 if (rel1
!= RELC_NONE
)
2156 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2159 case ETIR__C_OPR_COM
: /* Complement. */
2160 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2161 if (rel1
!= RELC_NONE
)
2163 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2166 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2167 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2168 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2169 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2172 (*_bfd_error_handler
) (_("invalid use of %s with contexts"),
2173 _bfd_vms_etir_name (cmd
));
2176 if ((int)op2
< 0) /* Shift right. */
2178 else /* Shift left. */
2180 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2183 case ETIR__C_OPR_INSV
: /* Insert field. */
2184 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2185 case ETIR__C_OPR_ROT
: /* Rotate. */
2186 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2187 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2188 (*_bfd_error_handler
) (_("%s: not supported"),
2189 _bfd_vms_etir_name (cmd
));
2193 case ETIR__C_OPR_SEL
: /* Select. */
2194 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2196 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2199 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2200 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2201 _bfd_vms_push (abfd
, op1
, rel1
);
2206 (*_bfd_error_handler
) (_("reserved cmd %d"), cmd
);
2211 ptr
+= cmd_length
- 4;
2217 /* Process EDBG/ETBT record.
2218 Return TRUE on success, FALSE on error */
2221 vms_slurp_debug (bfd
*abfd
)
2223 asection
*section
= PRIV (dst_section
);
2225 if (section
== NULL
)
2227 /* We have no way to find out beforehand how much debug info there
2228 is in an object file, so pick an initial amount and grow it as
2230 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2233 section
= bfd_make_section (abfd
, "$DST$");
2236 if (!bfd_set_section_flags (abfd
, section
, flags
))
2238 PRIV (dst_section
) = section
;
2241 PRIV (image_section
) = section
;
2242 PRIV (image_offset
) = section
->size
;
2244 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2247 section
->size
= PRIV (image_offset
);
2251 /* Process EDBG record.
2252 Return TRUE on success, FALSE on error. */
2255 _bfd_vms_slurp_edbg (bfd
*abfd
)
2257 vms_debug2 ((2, "EDBG\n"));
2259 abfd
->flags
|= HAS_DEBUG
| HAS_LINENO
;
2261 return vms_slurp_debug (abfd
);
2264 /* Process ETBT record.
2265 Return TRUE on success, FALSE on error. */
2268 _bfd_vms_slurp_etbt (bfd
*abfd
)
2270 vms_debug2 ((2, "ETBT\n"));
2272 abfd
->flags
|= HAS_LINENO
;
2274 return vms_slurp_debug (abfd
);
2277 /* Process EEOM record.
2278 Return TRUE on success, FALSE on error. */
2281 _bfd_vms_slurp_eeom (bfd
*abfd
)
2283 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2285 vms_debug2 ((2, "EEOM\n"));
2287 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2288 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2289 if (PRIV (eom_data
).eom_w_comcod
> 1)
2291 (*_bfd_error_handler
) (_("Object module NOT error-free !\n"));
2292 bfd_set_error (bfd_error_bad_value
);
2296 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2297 if (PRIV (recrd
.rec_size
) > 10)
2299 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2300 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2301 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2302 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2304 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2309 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2312 _bfd_vms_slurp_object_records (bfd
* abfd
)
2319 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2321 type
= _bfd_vms_get_object_record (abfd
);
2324 vms_debug2 ((2, "next_record failed\n"));
2331 err
= _bfd_vms_slurp_ehdr (abfd
);
2334 err
= _bfd_vms_slurp_eeom (abfd
);
2337 err
= _bfd_vms_slurp_egsd (abfd
);
2340 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2343 err
= _bfd_vms_slurp_edbg (abfd
);
2346 err
= _bfd_vms_slurp_etbt (abfd
);
2353 vms_debug2 ((2, "slurp type %d failed\n", type
));
2357 while (type
!= EOBJ__C_EEOM
);
2362 /* Initialize private data */
2364 vms_initialize (bfd
* abfd
)
2368 amt
= sizeof (struct vms_private_data_struct
);
2369 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2370 if (abfd
->tdata
.any
== NULL
)
2373 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2375 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2376 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2377 if (PRIV (stack
) == NULL
)
2383 bfd_release (abfd
, abfd
->tdata
.any
);
2384 abfd
->tdata
.any
= NULL
;
2388 /* Check the format for a file being read.
2389 Return a (bfd_target *) if it's an object file or zero if not. */
2391 static const struct bfd_target
*
2392 alpha_vms_object_p (bfd
*abfd
)
2394 PTR tdata_save
= abfd
->tdata
.any
;
2395 unsigned int test_len
;
2398 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2400 /* Allocate alpha-vms specific data. */
2401 if (!vms_initialize (abfd
))
2404 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2405 goto err_wrong_format
;
2407 /* The first challenge with VMS is to discover the kind of the file.
2409 Image files (executable or shared images) are stored as a raw
2410 stream of bytes (like on UNIX), but there is no magic number.
2412 Object files are written with RMS (record management service), ie
2413 each records are preceeded by its length (on a word - 2 bytes), and
2414 padded for word-alignment. That would be simple but when files
2415 are transfered to a UNIX filesystem (using ftp), records are lost.
2416 Only the raw content of the records are transfered. Fortunately,
2417 the Alpha Object file format also store the length of the record
2418 in the records. Is that clear ? */
2420 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2421 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2422 4 bytes minor id, 4 bytes length). */
2425 /* Size the main buffer. */
2426 buf
= (unsigned char *) bfd_malloc (test_len
);
2429 PRIV (recrd
.buf
) = buf
;
2430 PRIV (recrd
.buf_size
) = test_len
;
2432 /* Initialize the record pointer. */
2433 PRIV (recrd
.rec
) = buf
;
2435 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2437 bfd_set_error (bfd_error_file_truncated
);
2441 /* Is it an image? */
2442 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2443 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2445 unsigned int to_read
;
2446 unsigned int read_so_far
;
2447 unsigned int remaining
;
2448 unsigned int eisd_offset
, eihs_offset
;
2450 /* Extract the header size. */
2451 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2453 /* The header size is 0 for DSF files. */
2454 if (PRIV (recrd
.rec_size
) == 0)
2455 PRIV (recrd
.rec_size
) = sizeof (struct vms_eihd
);
2457 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2459 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2463 PRIV (recrd
.buf
) = NULL
;
2464 bfd_set_error (bfd_error_no_memory
);
2467 PRIV (recrd
.buf
) = buf
;
2468 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2471 /* Read the remaining record. */
2472 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2473 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2474 read_so_far
= test_len
;
2476 while (remaining
> 0)
2478 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2480 bfd_set_error (bfd_error_file_truncated
);
2481 goto err_wrong_format
;
2484 read_so_far
+= to_read
;
2485 remaining
-= to_read
;
2487 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2490 /* Reset the record pointer. */
2491 PRIV (recrd
.rec
) = buf
;
2493 vms_debug2 ((2, "file type is image\n"));
2495 if (_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
) != TRUE
)
2496 goto err_wrong_format
;
2498 if (_bfd_vms_slurp_eisd (abfd
, eisd_offset
) != TRUE
)
2499 goto err_wrong_format
;
2501 /* EIHS is optional. */
2502 if (eihs_offset
!= 0 && _bfd_vms_slurp_eihs (abfd
, eihs_offset
) != TRUE
)
2503 goto err_wrong_format
;
2509 /* Assume it's a module and adjust record pointer if necessary. */
2510 maybe_adjust_record_pointer_for_object (abfd
);
2512 /* But is it really a module? */
2513 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2514 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2516 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2517 goto err_wrong_format
;
2519 vms_debug2 ((2, "file type is module\n"));
2521 type
= bfd_getl16 (PRIV (recrd
.rec
));
2522 if (type
!= EOBJ__C_EMH
|| _bfd_vms_slurp_ehdr (abfd
) != TRUE
)
2523 goto err_wrong_format
;
2525 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
2526 goto err_wrong_format
;
2529 goto err_wrong_format
;
2532 /* Set arch_info to alpha. */
2534 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2535 goto err_wrong_format
;
2540 bfd_set_error (bfd_error_wrong_format
);
2543 if (PRIV (recrd
.buf
))
2544 free (PRIV (recrd
.buf
));
2545 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2546 bfd_release (abfd
, abfd
->tdata
.any
);
2547 abfd
->tdata
.any
= tdata_save
;
2554 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2556 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2559 if (vec
->max_el
== 0)
2562 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2567 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2571 /* Bump ABFD file position to next block. */
2574 alpha_vms_file_position_block (bfd
*abfd
)
2577 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2578 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2581 /* Convert from internal structure SRC to external structure DST. */
2584 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2585 struct vms_eisd
*dst
)
2587 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2588 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2589 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2590 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2592 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2593 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2594 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2595 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2596 dst
->pfc
= src
->u
.eisd
.pfc
;
2597 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2598 dst
->type
= src
->u
.eisd
.type
;
2600 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2602 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2603 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2604 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2608 /* Append EISD to the list of extra eisd for ABFD. */
2611 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2614 if (PRIV (gbl_eisd_head
) == NULL
)
2615 PRIV (gbl_eisd_head
) = eisd
;
2617 PRIV (gbl_eisd_tail
)->next
= eisd
;
2618 PRIV (gbl_eisd_tail
) = eisd
;
2621 /* Create an EISD for shared image SHRIMG.
2622 Return FALSE in case of error. */
2625 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2627 struct vms_internal_eisd_map
*eisd
;
2630 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2631 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2637 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2641 /* Fill the fields. */
2642 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2643 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2644 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2645 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2646 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2647 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2648 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2649 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2650 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2651 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2653 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2654 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2655 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2657 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2659 /* Append it to the list. */
2660 alpha_vms_append_extra_eisd (abfd
, eisd
);
2665 /* Create an EISD for section SEC.
2666 Return FALSE in case of failure. */
2669 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2671 struct vms_internal_eisd_map
*eisd
;
2673 /* Only for allocating section. */
2674 if (!(sec
->flags
& SEC_ALLOC
))
2677 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2678 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2681 vms_section_data (sec
)->eisd
= eisd
;
2683 /* Fill the fields. */
2684 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2685 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2686 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2687 eisd
->u
.eisd
.secsize
=
2688 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2689 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2690 eisd
->u
.eisd
.flags
= 0;
2691 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2692 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2693 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2694 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2696 if (sec
->flags
& SEC_CODE
)
2697 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2698 if (!(sec
->flags
& SEC_READONLY
))
2699 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2701 if (!(sec
->flags
& SEC_LOAD
))
2703 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
2704 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
2706 if (sec
->flags
& SEC_LINKER_CREATED
)
2708 if (strcmp (sec
->name
, "$FIXUP$") == 0)
2709 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
2712 /* Append it to the list. */
2714 if (PRIV (eisd_head
) == NULL
)
2715 PRIV (eisd_head
) = eisd
;
2717 PRIV (eisd_tail
)->next
= eisd
;
2718 PRIV (eisd_tail
) = eisd
;
2723 /* Layout executable ABFD and write it to the disk.
2724 Return FALSE in case of failure. */
2727 alpha_vms_write_exec (bfd
*abfd
)
2729 struct vms_eihd eihd
;
2730 struct vms_eiha
*eiha
;
2731 struct vms_eihi
*eihi
;
2732 struct vms_eihs
*eihs
= NULL
;
2734 struct vms_internal_eisd_map
*first_eisd
;
2735 struct vms_internal_eisd_map
*eisd
;
2739 /* Build the EIHD. */
2740 PRIV (file_pos
) = EIHD__C_LENGTH
;
2742 memset (&eihd
, 0, sizeof (eihd
));
2743 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
2745 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
2746 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
2748 bfd_putl32 (sizeof (eihd
), eihd
.size
);
2749 bfd_putl32 (0, eihd
.isdoff
);
2750 bfd_putl32 (0, eihd
.activoff
);
2751 bfd_putl32 (0, eihd
.symdbgoff
);
2752 bfd_putl32 (0, eihd
.imgidoff
);
2753 bfd_putl32 (0, eihd
.patchoff
);
2754 bfd_putl64 (0, eihd
.iafva
);
2755 bfd_putl32 (0, eihd
.version_array_off
);
2757 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
2758 bfd_putl32 (0, eihd
.subtype
);
2760 bfd_putl32 (0, eihd
.imgiocnt
);
2761 bfd_putl32 (-1, eihd
.privreqs
);
2762 bfd_putl32 (-1, eihd
.privreqs
+ 4);
2764 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2766 bfd_putl32 (0, eihd
.lnkflags
);
2767 bfd_putl32 (0, eihd
.ident
);
2768 bfd_putl32 (0, eihd
.sysver
);
2771 bfd_putl32 (0, eihd
.symvect_size
);
2772 bfd_putl32 (16, eihd
.virt_mem_block_size
);
2773 bfd_putl32 (0, eihd
.ext_fixup_off
);
2774 bfd_putl32 (0, eihd
.noopt_psect_off
);
2775 bfd_putl32 (-1, eihd
.alias
);
2778 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
2779 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
2780 PRIV (file_pos
) += sizeof (struct vms_eiha
);
2782 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
2783 bfd_putl32 (0, eiha
->spare
);
2784 bfd_putl32 (0x00000340, eiha
->tfradr1
); /* SYS$IMGACT */
2785 bfd_putl32 (0xffffffff, eiha
->tfradr1_h
);
2786 bfd_putl64 (bfd_get_start_address (abfd
), eiha
->tfradr2
);
2787 bfd_putl64 (0, eiha
->tfradr3
);
2788 bfd_putl64 (0, eiha
->tfradr4
);
2789 bfd_putl64 (0, eiha
->inishr
);
2792 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
2793 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
2794 PRIV (file_pos
) += sizeof (struct vms_eihi
);
2796 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
2797 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
2802 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2803 len
= strlen (module
);
2804 if (len
> sizeof (eihi
->imgnam
) - 1)
2805 len
= sizeof (eihi
->imgnam
) - 1;
2806 eihi
->imgnam
[0] = len
;
2807 memcpy (eihi
->imgnam
+ 1, module
, len
);
2810 bfd_putl32 (0, eihi
->linktime
+ 0);
2811 bfd_putl32 (0, eihi
->linktime
+ 4);
2813 eihi
->linkid
[0] = 0;
2814 eihi
->imgbid
[0] = 0;
2817 dst
= PRIV (dst_section
);
2818 dmt
= bfd_get_section_by_name (abfd
, "$DMT$");
2819 if (dst
!= NULL
&& dst
->size
!= 0)
2821 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
2822 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
2823 PRIV (file_pos
) += sizeof (struct vms_eihs
);
2825 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
2826 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
2827 bfd_putl32 (0, eihs
->dstvbn
);
2828 bfd_putl32 (0, eihs
->dstsize
);
2829 bfd_putl32 (0, eihs
->gstvbn
);
2830 bfd_putl32 (0, eihs
->gstsize
);
2831 bfd_putl32 (0, eihs
->dmtvbn
);
2832 bfd_putl32 (0, eihs
->dmtsize
);
2835 /* One EISD per section. */
2836 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2838 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
2842 /* Merge section EIDS which extra ones. */
2843 if (PRIV (eisd_tail
))
2844 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
2846 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
2847 if (PRIV (gbl_eisd_tail
))
2848 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
2850 first_eisd
= PRIV (eisd_head
);
2852 /* Add end of eisd. */
2855 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
2858 eisd
->u
.eisd
.majorid
= 0;
2859 eisd
->u
.eisd
.minorid
= 0;
2860 eisd
->u
.eisd
.eisdsize
= 0;
2861 alpha_vms_append_extra_eisd (abfd
, eisd
);
2864 /* Place EISD in the file. */
2865 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
2867 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2869 /* First block is a little bit special: there is a word at the end. */
2870 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
2872 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
2873 alpha_vms_file_position_block (abfd
);
2875 eisd
->file_pos
= PRIV (file_pos
);
2876 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
2878 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
2879 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
2882 if (first_eisd
!= NULL
)
2884 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
2885 /* Real size of end of eisd marker. */
2886 PRIV (file_pos
) += EISD__K_LENEND
;
2889 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
2890 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2893 /* Place sections. */
2894 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2896 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
2899 eisd
= vms_section_data (sec
)->eisd
;
2901 /* Align on a block. */
2902 alpha_vms_file_position_block (abfd
);
2903 sec
->filepos
= PRIV (file_pos
);
2906 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
2908 PRIV (file_pos
) += sec
->size
;
2911 if (eihs
!= NULL
&& dst
!= NULL
)
2913 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
2914 bfd_putl32 (dst
->size
, eihs
->dstsize
);
2918 bfd_putl32 ((dmt
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dmtvbn
);
2919 bfd_putl32 (dmt
->size
, eihs
->dmtsize
);
2923 /* Write EISD in hdr. */
2924 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
2926 alpha_vms_swap_eisd_out
2927 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
2929 /* Write first block. */
2930 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
2933 /* Write remaining eisd. */
2936 unsigned char blk
[VMS_BLOCK_SIZE
];
2937 struct vms_internal_eisd_map
*next_eisd
;
2939 memset (blk
, 0xff, sizeof (blk
));
2940 while (eisd
!= NULL
)
2942 alpha_vms_swap_eisd_out
2944 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
2946 next_eisd
= eisd
->next
;
2947 if (next_eisd
== NULL
2948 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
2949 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
2951 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
2954 memset (blk
, 0xff, sizeof (blk
));
2960 /* Write sections. */
2961 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2963 unsigned char blk
[VMS_BLOCK_SIZE
];
2966 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
2968 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
2972 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
2973 if (len
!= VMS_BLOCK_SIZE
)
2975 memset (blk
, 0, len
);
2976 if (bfd_bwrite (blk
, len
, abfd
) != len
)
2986 /* This hash routine borrowed from GNU-EMACS, and strengthened
2990 hash_string (const char *ptr
)
2992 const unsigned char *p
= (unsigned char *) ptr
;
2993 const unsigned char *end
= p
+ strlen (ptr
);
3000 hash
= ((hash
<< 3) + (hash
<< 15) + (hash
>> 28) + c
);
3005 /* Generate a length-hashed VMS symbol name (limited to maxlen chars). */
3008 _bfd_vms_length_hash_symbol (bfd
*abfd
, const char *in
, int maxlen
)
3010 unsigned long result
;
3013 const char *old_name
;
3015 static char outbuf
[EOBJ__C_SYMSIZ
+ 1];
3019 vms_debug (4, "_bfd_vms_length_hash_symbol \"%s\"\n", in
);
3022 if (maxlen
> EOBJ__C_SYMSIZ
)
3023 maxlen
= EOBJ__C_SYMSIZ
;
3025 /* Save this for later. */
3028 /* We may need to truncate the symbol, save the hash for later. */
3029 in_len
= strlen (in
);
3031 result
= (in_len
> maxlen
) ? hash_string (in
) : 0;
3035 /* Do the length checking. */
3036 if (in_len
<= maxlen
)
3040 if (PRIV (flag_hash_long_names
))
3046 strncpy (out
, in
, (size_t) i
);
3050 if ((in_len
> maxlen
)
3051 && PRIV (flag_hash_long_names
))
3052 sprintf (out
, "_%08lx", result
);
3057 vms_debug (4, "--> [%d]\"%s\"\n", (int)strlen (outbuf
), outbuf
);
3061 && PRIV (flag_hash_long_names
)
3062 && PRIV (flag_show_after_trunc
))
3063 printf (_("Symbol %s replaced by %s\n"), old_name
, new_name
);
3068 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3071 _bfd_vms_write_egsd (bfd
*abfd
)
3075 unsigned int symnum
;
3076 int last_index
= -1;
3077 char dummy_name
[10];
3079 flagword new_flags
, old_flags
;
3080 int abs_section_index
= 0;
3081 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3083 vms_debug2 ((2, "vms_write_gsd\n"));
3085 /* Output sections. */
3086 section
= abfd
->sections
;
3087 vms_debug2 ((3, "%d sections found\n", abfd
->section_count
));
3089 /* Egsd is quadword aligned. */
3090 _bfd_vms_output_alignment (recwr
, 8);
3092 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3093 _bfd_vms_output_long (recwr
, 0);
3095 while (section
!= 0)
3097 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3098 section
->index
, section
->name
, (int)section
->size
));
3100 /* Don't write out the VMS debug info section since it is in the
3101 ETBT and EDBG sections in etir. */
3102 if (!strcmp (section
->name
, ".vmsdebug"))
3105 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3106 if (_bfd_vms_output_check (recwr
, 64) < 0)
3108 _bfd_vms_output_end (abfd
, recwr
);
3109 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3110 _bfd_vms_output_long (recwr
, 0);
3113 /* Create dummy sections to keep consecutive indices. */
3114 while (section
->index
- last_index
> 1)
3116 vms_debug2 ((3, "index %d, last %d\n", section
->index
, last_index
));
3117 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3118 _bfd_vms_output_short (recwr
, 0);
3119 _bfd_vms_output_short (recwr
, 0);
3120 _bfd_vms_output_long (recwr
, 0);
3121 sprintf (dummy_name
, ".DUMMY%02d", last_index
);
3122 _bfd_vms_output_counted (recwr
, dummy_name
);
3123 _bfd_vms_output_end_subrec (recwr
);
3127 /* Don't know if this is necessary for the linker but for now it keeps
3128 vms_slurp_gsd happy */
3129 sname
= (char *)section
->name
;
3133 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3134 sname
= EVAX_CODE_NAME
;
3135 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3136 sname
= EVAX_DATA_NAME
;
3137 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3138 sname
= EVAX_BSS_NAME
;
3139 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3140 sname
= EVAX_LINK_NAME
;
3141 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3142 sname
= EVAX_READONLY_NAME
;
3143 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3144 sname
= EVAX_LITERAL_NAME
;
3145 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3147 sname
= EVAX_LITERALS_NAME
;
3148 abs_section_index
= section
->index
;
3150 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3151 sname
= EVAX_COMMON_NAME
;
3152 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3153 sname
= EVAX_LOCAL_NAME
;
3156 sname
= _bfd_vms_length_hash_symbol (abfd
, sname
, EOBJ__C_SECSIZ
);
3158 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3159 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3161 if (bfd_is_com_section (section
))
3162 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3163 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3165 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3168 /* Modify them as directed. */
3169 if (section
->flags
& SEC_READONLY
)
3170 new_flags
&= ~EGPS__V_WRT
;
3172 new_flags
&= ~vms_section_data (section
)->no_flags
;
3173 new_flags
|= vms_section_data (section
)->flags
;
3175 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3176 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3177 new_flags
, (unsigned long)section
->size
));
3179 _bfd_vms_output_short (recwr
, new_flags
);
3180 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3181 _bfd_vms_output_counted (recwr
, sname
);
3182 _bfd_vms_output_end_subrec (recwr
);
3184 last_index
= section
->index
;
3186 section
= section
->next
;
3189 /* Output symbols. */
3190 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3192 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3194 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3198 symbol
= abfd
->outsymbols
[symnum
];
3199 if (*(symbol
->name
) == '_')
3201 if (strcmp (symbol
->name
, "__main") == 0)
3202 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3204 old_flags
= symbol
->flags
;
3206 if (old_flags
& BSF_FILE
)
3209 if ((old_flags
& BSF_GLOBAL
) == 0 /* Not xdef... */
3210 && !bfd_is_und_section (symbol
->section
) /* and not xref... */
3211 && !((old_flags
& BSF_SECTION_SYM
) != 0 /* and not LIB$INITIALIZE. */
3212 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3215 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. */
3216 if (_bfd_vms_output_check (recwr
, 80) < 0)
3218 _bfd_vms_output_end (abfd
, recwr
);
3219 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3220 _bfd_vms_output_long (recwr
, 0);
3223 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3225 /* Data type, alignment. */
3226 _bfd_vms_output_short (recwr
, 0);
3230 if (old_flags
& BSF_WEAK
)
3231 new_flags
|= EGSY__V_WEAK
;
3232 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3233 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3235 if (old_flags
& BSF_FUNCTION
)
3237 new_flags
|= EGSY__V_NORM
;
3238 new_flags
|= EGSY__V_REL
;
3240 if (old_flags
& BSF_GLOBAL
)
3242 new_flags
|= EGSY__V_DEF
;
3243 if (!bfd_is_abs_section (symbol
->section
))
3244 new_flags
|= EGSY__V_REL
;
3246 _bfd_vms_output_short (recwr
, new_flags
);
3248 if (old_flags
& BSF_GLOBAL
)
3250 /* Symbol definition. */
3251 bfd_vma code_address
= 0;
3252 unsigned long ca_psindx
= 0;
3253 unsigned long psindx
;
3255 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3259 sym
= ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3260 code_address
= sym
->value
;
3261 ca_psindx
= sym
->section
->index
;
3263 if (bfd_is_abs_section (symbol
->section
))
3264 psindx
= abs_section_index
;
3266 psindx
= symbol
->section
->index
;
3268 _bfd_vms_output_quad (recwr
, symbol
->value
);
3269 _bfd_vms_output_quad (recwr
, code_address
);
3270 _bfd_vms_output_long (recwr
, ca_psindx
);
3271 _bfd_vms_output_long (recwr
, psindx
);
3273 hash
= _bfd_vms_length_hash_symbol (abfd
, symbol
->name
, EOBJ__C_SYMSIZ
);
3274 _bfd_vms_output_counted (recwr
, hash
);
3276 _bfd_vms_output_end_subrec (recwr
);
3280 _bfd_vms_output_alignment (recwr
, 8);
3281 _bfd_vms_output_end (abfd
, recwr
);
3286 /* Write object header for bfd abfd. Return FALSE on error. */
3289 _bfd_vms_write_ehdr (bfd
*abfd
)
3292 unsigned int symnum
;
3296 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3298 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3300 _bfd_vms_output_alignment (recwr
, 2);
3303 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3304 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
3305 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
3306 _bfd_vms_output_long (recwr
, 0);
3307 _bfd_vms_output_long (recwr
, 0);
3308 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
3310 /* Create module name from filename. */
3311 if (bfd_get_filename (abfd
) != 0)
3313 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3314 _bfd_vms_output_counted (recwr
, module
);
3318 _bfd_vms_output_counted (recwr
, "NONAME");
3320 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
3321 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
3322 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
3323 _bfd_vms_output_end (abfd
, recwr
);
3326 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3327 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
3328 snprintf (version
, sizeof (version
), "GAS BFD v%s", BFD_VERSION_STRING
);
3329 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
3330 _bfd_vms_output_end (abfd
, recwr
);
3333 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3334 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3336 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3338 symbol
= abfd
->outsymbols
[symnum
];
3340 if (symbol
->flags
& BSF_FILE
)
3342 if (CONST_STRNEQ ((char *)symbol
->name
, "<CASE:"))
3344 PRIV (flag_hash_long_names
) = symbol
->name
[6] - '0';
3345 PRIV (flag_show_after_trunc
) = symbol
->name
[7] - '0';
3353 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3354 (int) strlen (symbol
->name
));
3361 if (symnum
== abfd
->symcount
)
3362 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3364 _bfd_vms_output_end (abfd
, recwr
);
3367 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3368 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3369 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3370 _bfd_vms_output_end (abfd
, recwr
);
3373 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3374 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3375 _bfd_vms_output_dump (recwr
,
3376 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3378 _bfd_vms_output_end (abfd
, recwr
);
3383 /* Part 4.6, relocations. */
3386 /* WRITE ETIR SECTION
3388 This is still under construction and therefore not documented. */
3390 /* Close the etir/etbt record. */
3393 end_etir_record (bfd
* abfd
)
3395 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3397 _bfd_vms_output_end (abfd
, recwr
);
3401 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3403 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3405 if (section
->name
[0] == '.' && section
->name
[1] == 'v'
3406 && !strcmp (section
->name
, ".vmsdebug"))
3408 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3412 /* Push start offset. */
3413 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3414 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3415 _bfd_vms_output_end_subrec (recwr
);
3418 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3419 _bfd_vms_output_end_subrec (recwr
);
3424 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3428 /* Push start offset. */
3429 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3430 _bfd_vms_output_long (recwr
, (unsigned long) section
->index
);
3431 _bfd_vms_output_quad (recwr
, offset
);
3432 _bfd_vms_output_end_subrec (recwr
);
3434 /* Start = pop (). */
3435 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3436 _bfd_vms_output_end_subrec (recwr
);
3441 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3442 address VADDR in section specified by SEC_INDEX and NAME. */
3445 sto_imm (bfd
*abfd
, asection
*section
,
3446 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3449 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3452 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3453 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3458 /* Try all the rest. */
3461 if (_bfd_vms_output_check (recwr
, size
) < 0)
3463 /* Doesn't fit, split ! */
3464 end_etir_record (abfd
);
3466 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3468 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3469 if (size
> ssize
) /* more than what's left ? */
3473 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3474 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3475 _bfd_vms_output_dump (recwr
, cptr
, size
);
3476 _bfd_vms_output_end_subrec (recwr
);
3479 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3480 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3490 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3492 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3494 /* Not enough room in this record. Close it and open a new one. */
3495 end_etir_record (abfd
);
3496 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3500 /* Return whether RELOC must be deferred till the end. */
3503 defer_reloc_p (arelent
*reloc
)
3505 switch (reloc
->howto
->type
)
3518 /* Write section contents for bfd abfd. Return FALSE on error. */
3521 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3524 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3526 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3528 _bfd_vms_output_alignment (recwr
, 4);
3530 PRIV (vms_linkage_index
) = 1;
3532 for (section
= abfd
->sections
; section
; section
= section
->next
)
3534 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3535 section
->index
, section
->name
, (int) (section
->size
)));
3537 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3538 || bfd_is_com_section (section
))
3541 if (!section
->contents
)
3543 bfd_set_error (bfd_error_no_contents
);
3547 start_etir_or_etbt_record (abfd
, section
, 0);
3549 if (section
->flags
& SEC_RELOC
)
3551 bfd_vma curr_addr
= 0;
3552 unsigned char *curr_data
= section
->contents
;
3554 int pass2_needed
= 0;
3555 int pass2_in_progress
= 0;
3558 if (section
->reloc_count
<= 0)
3559 (*_bfd_error_handler
)
3560 (_("SEC_RELOC with no relocs in section %s"), section
->name
);
3565 int i
= section
->reloc_count
;
3566 arelent
**rptr
= section
->orelocation
;
3567 _bfd_vms_debug (4, "%d relocations:\n", i
);
3570 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3571 "addr %08lx, off %08lx, len %d: %s\n",
3572 (*(*rptr
)->sym_ptr_ptr
)->name
,
3573 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3574 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3575 (unsigned long)(*rptr
)->address
,
3576 (unsigned long)(*rptr
)->addend
,
3577 bfd_get_reloc_size ((*rptr
)->howto
),
3578 ( *rptr
)->howto
->name
);
3585 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3587 struct evax_private_udata_struct
*udata
;
3588 arelent
*rptr
= section
->orelocation
[irel
];
3589 bfd_vma addr
= rptr
->address
;
3590 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3591 asection
*sec
= sym
->section
;
3592 bfd_boolean defer
= defer_reloc_p (rptr
);
3596 if (pass2_in_progress
)
3598 /* Non-deferred relocs have already been output. */
3604 /* Deferred relocs must be output at the very end. */
3611 /* Regular relocs are intertwined with binary data. */
3612 if (curr_addr
> addr
)
3613 (*_bfd_error_handler
) (_("Size error in section %s"),
3615 size
= addr
- curr_addr
;
3616 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3621 size
= bfd_get_reloc_size (rptr
->howto
);
3623 switch (rptr
->howto
->type
)
3625 case ALPHA_R_IGNORE
:
3628 case ALPHA_R_REFLONG
:
3629 if (bfd_is_und_section (sym
->section
))
3631 bfd_vma addend
= rptr
->addend
;
3632 slen
= strlen ((char *) sym
->name
);
3633 hash
= _bfd_vms_length_hash_symbol
3634 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3635 etir_output_check (abfd
, section
, curr_addr
, slen
);
3638 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3639 _bfd_vms_output_counted (recwr
, hash
);
3640 _bfd_vms_output_end_subrec (recwr
);
3641 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3642 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3643 _bfd_vms_output_end_subrec (recwr
);
3644 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3645 _bfd_vms_output_end_subrec (recwr
);
3646 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3647 _bfd_vms_output_end_subrec (recwr
);
3651 _bfd_vms_output_begin_subrec
3652 (recwr
, ETIR__C_STO_GBL_LW
);
3653 _bfd_vms_output_counted (recwr
, hash
);
3654 _bfd_vms_output_end_subrec (recwr
);
3657 else if (bfd_is_abs_section (sym
->section
))
3659 etir_output_check (abfd
, section
, curr_addr
, 16);
3660 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3661 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3662 _bfd_vms_output_end_subrec (recwr
);
3663 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3664 _bfd_vms_output_end_subrec (recwr
);
3668 etir_output_check (abfd
, section
, curr_addr
, 32);
3669 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3670 _bfd_vms_output_long (recwr
, (unsigned long) sec
->index
);
3671 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3672 _bfd_vms_output_end_subrec (recwr
);
3673 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3674 says that we should have a ETIR__C_STO_OFF here.
3675 But the relocation would not be BFD_RELOC_32 then.
3676 This case is very likely unreachable. */
3677 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3678 _bfd_vms_output_end_subrec (recwr
);
3682 case ALPHA_R_REFQUAD
:
3683 if (bfd_is_und_section (sym
->section
))
3685 bfd_vma addend
= rptr
->addend
;
3686 slen
= strlen ((char *) sym
->name
);
3687 hash
= _bfd_vms_length_hash_symbol
3688 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3689 etir_output_check (abfd
, section
, curr_addr
, slen
);
3692 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3693 _bfd_vms_output_counted (recwr
, hash
);
3694 _bfd_vms_output_end_subrec (recwr
);
3695 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3696 _bfd_vms_output_quad (recwr
, addend
);
3697 _bfd_vms_output_end_subrec (recwr
);
3698 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3699 _bfd_vms_output_end_subrec (recwr
);
3700 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3701 _bfd_vms_output_end_subrec (recwr
);
3705 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3706 _bfd_vms_output_counted (recwr
, hash
);
3707 _bfd_vms_output_end_subrec (recwr
);
3710 else if (bfd_is_abs_section (sym
->section
))
3712 etir_output_check (abfd
, section
, curr_addr
, 16);
3713 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3714 _bfd_vms_output_quad (recwr
, sym
->value
);
3715 _bfd_vms_output_end_subrec (recwr
);
3716 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3717 _bfd_vms_output_end_subrec (recwr
);
3721 etir_output_check (abfd
, section
, curr_addr
, 32);
3722 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3723 _bfd_vms_output_long (recwr
, (unsigned long) sec
->index
);
3724 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3725 _bfd_vms_output_end_subrec (recwr
);
3726 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3727 _bfd_vms_output_end_subrec (recwr
);
3732 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3735 case ALPHA_R_LINKAGE
:
3736 etir_output_check (abfd
, section
, curr_addr
, 64);
3737 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
3738 _bfd_vms_output_long
3739 (recwr
, (unsigned long) PRIV (vms_linkage_index
));
3740 PRIV (vms_linkage_index
) += 2;
3741 hash
= _bfd_vms_length_hash_symbol
3742 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3743 _bfd_vms_output_counted (recwr
, hash
);
3744 _bfd_vms_output_byte (recwr
, 0);
3745 _bfd_vms_output_end_subrec (recwr
);
3748 case ALPHA_R_CODEADDR
:
3749 slen
= strlen ((char *) sym
->name
);
3750 hash
= _bfd_vms_length_hash_symbol
3751 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3752 etir_output_check (abfd
, section
, curr_addr
, slen
);
3753 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
3754 _bfd_vms_output_counted (recwr
, hash
);
3755 _bfd_vms_output_end_subrec (recwr
);
3760 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3761 etir_output_check (abfd
, section
, curr_addr
,
3762 32 + 1 + strlen (udata
->origname
));
3763 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
3764 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3765 _bfd_vms_output_long
3766 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3767 _bfd_vms_output_quad (recwr
, rptr
->address
);
3768 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
3769 _bfd_vms_output_long
3770 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3771 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3772 _bfd_vms_output_counted
3773 (recwr
, _bfd_vms_length_hash_symbol
3774 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3775 _bfd_vms_output_end_subrec (recwr
);
3779 (*_bfd_error_handler
) (_("Spurious ALPHA_R_BSR reloc"));
3784 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3785 etir_output_check (abfd
, section
, curr_addr
,
3786 32 + 1 + strlen (udata
->origname
));
3787 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
3788 _bfd_vms_output_long
3789 (recwr
, (unsigned long) udata
->lkindex
+ 1);
3790 _bfd_vms_output_long
3791 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3792 _bfd_vms_output_quad (recwr
, rptr
->address
);
3793 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
3794 _bfd_vms_output_long
3795 (recwr
, (unsigned long) udata
->bsym
->section
->index
);
3796 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3797 _bfd_vms_output_counted
3798 (recwr
, _bfd_vms_length_hash_symbol
3799 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3800 _bfd_vms_output_end_subrec (recwr
);
3805 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3806 etir_output_check (abfd
, section
, curr_addr
,
3807 32 + 1 + strlen (udata
->origname
));
3808 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
3809 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3810 _bfd_vms_output_long
3811 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3812 _bfd_vms_output_quad (recwr
, rptr
->address
);
3813 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
3814 _bfd_vms_output_long
3815 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3816 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3817 _bfd_vms_output_counted
3818 (recwr
, _bfd_vms_length_hash_symbol
3819 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3820 _bfd_vms_output_end_subrec (recwr
);
3824 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
3831 } /* End of relocs loop. */
3833 if (!pass2_in_progress
)
3835 /* Output rest of section. */
3836 if (curr_addr
> section
->size
)
3837 (*_bfd_error_handler
) (_("Size error in section %s"),
3839 size
= section
->size
- curr_addr
;
3840 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3846 pass2_in_progress
= 1;
3852 else /* (section->flags & SEC_RELOC) */
3853 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
3855 end_etir_record (abfd
);
3858 _bfd_vms_output_alignment (recwr
, 2);
3862 /* Write eom record for bfd abfd. Return FALSE on error. */
3865 _bfd_vms_write_eeom (bfd
*abfd
)
3867 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3869 vms_debug2 ((2, "vms_write_eeom\n"));
3871 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
3872 _bfd_vms_output_long (recwr
, (unsigned long) (PRIV (vms_linkage_index
) >> 1));
3873 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
3874 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
3876 if (bfd_get_start_address (abfd
) != (bfd_vma
)-1)
3880 section
= bfd_get_section_by_name (abfd
, ".link");
3883 bfd_set_error (bfd_error_nonrepresentable_section
);
3886 _bfd_vms_output_short (recwr
, 0);
3887 _bfd_vms_output_long (recwr
, (unsigned long) (section
->index
));
3888 _bfd_vms_output_long (recwr
,
3889 (unsigned long) bfd_get_start_address (abfd
));
3890 _bfd_vms_output_long (recwr
, 0);
3893 _bfd_vms_output_end (abfd
, recwr
);
3897 /* Write cached information into a file being written, at bfd_close. */
3900 alpha_vms_write_object_contents (bfd
*abfd
)
3902 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
3904 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3906 return alpha_vms_write_exec (abfd
);
3910 if (abfd
->section_count
> 0) /* we have sections */
3912 if (_bfd_vms_write_ehdr (abfd
) != TRUE
)
3914 if (_bfd_vms_write_egsd (abfd
) != TRUE
)
3916 if (_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
) != TRUE
)
3918 if (_bfd_vms_write_eeom (abfd
) != TRUE
)
3925 /* Debug stuff: nearest line. */
3927 #define SET_MODULE_PARSED(m) \
3928 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
3929 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
3931 /* Build a new module for the specified BFD. */
3933 static struct module
*
3934 new_module (bfd
*abfd
)
3936 struct module
*module
3937 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
3938 module
->file_table_count
= 16; /* Arbitrary. */
3940 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
3944 /* Parse debug info for a module and internalize it. */
3947 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
3950 unsigned char *maxptr
= ptr
+ length
;
3951 unsigned char *src_ptr
, *pcl_ptr
;
3952 unsigned int prev_linum
= 0, curr_linenum
= 0;
3953 bfd_vma prev_pc
= 0, curr_pc
= 0;
3954 struct srecinfo
*curr_srec
, *srec
;
3955 struct lineinfo
*curr_line
, *line
;
3956 struct funcinfo
*funcinfo
;
3958 /* Initialize tables with zero element. */
3959 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
3960 module
->srec_table
= curr_srec
;
3962 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
3963 module
->line_table
= curr_line
;
3965 while (length
== -1 || ptr
< maxptr
)
3967 /* The first byte is not counted in the recorded length. */
3968 int rec_length
= bfd_getl16 (ptr
) + 1;
3969 int rec_type
= bfd_getl16 (ptr
+ 2);
3971 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
3973 if (length
== -1 && rec_type
== DST__K_MODEND
)
3980 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
);
3987 vms_debug2 ((3, "module: %s\n", module
->name
));
3994 funcinfo
= (struct funcinfo
*)
3995 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
3997 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
);
3998 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
3999 funcinfo
->next
= module
->func_table
;
4000 module
->func_table
= funcinfo
;
4002 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4003 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4007 module
->func_table
->high
= module
->func_table
->low
4008 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4010 if (module
->func_table
->high
> module
->high
)
4011 module
->high
= module
->func_table
->high
;
4013 vms_debug2 ((3, "end routine\n"));
4017 vms_debug2 ((3, "prologue\n"));
4021 vms_debug2 ((3, "epilog\n"));
4025 vms_debug2 ((3, "block\n"));
4029 vms_debug2 ((3, "end block\n"));
4033 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4035 vms_debug2 ((3, "source info\n"));
4037 while (src_ptr
< ptr
+ rec_length
)
4039 int cmd
= src_ptr
[0], cmd_length
, data
;
4043 case DST__K_SRC_DECLFILE
:
4046 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4048 = _bfd_vms_save_counted_string (src_ptr
4049 + DST_S_B_SRC_DF_FILENAME
);
4051 while (fileid
>= module
->file_table_count
)
4053 module
->file_table_count
*= 2;
4055 = bfd_realloc (module
->file_table
,
4056 module
->file_table_count
4057 * sizeof (struct fileinfo
));
4060 module
->file_table
[fileid
].name
= filename
;
4061 module
->file_table
[fileid
].srec
= 1;
4062 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4063 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4064 fileid
, module
->file_table
[fileid
].name
));
4068 case DST__K_SRC_DEFLINES_B
:
4069 /* Perform the association and set the next higher index
4071 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4072 srec
= (struct srecinfo
*)
4073 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4074 srec
->line
= curr_srec
->line
+ data
;
4075 srec
->srec
= curr_srec
->srec
+ data
;
4076 srec
->sfile
= curr_srec
->sfile
;
4077 curr_srec
->next
= srec
;
4080 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4083 case DST__K_SRC_DEFLINES_W
:
4084 /* Perform the association and set the next higher index
4086 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4087 srec
= (struct srecinfo
*)
4088 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4089 srec
->line
= curr_srec
->line
+ data
;
4090 srec
->srec
= curr_srec
->srec
+ data
,
4091 srec
->sfile
= curr_srec
->sfile
;
4092 curr_srec
->next
= srec
;
4095 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4098 case DST__K_SRC_INCRLNUM_B
:
4099 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4100 curr_srec
->line
+= data
;
4102 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4105 case DST__K_SRC_SETFILE
:
4106 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4107 curr_srec
->sfile
= data
;
4108 curr_srec
->srec
= module
->file_table
[data
].srec
;
4110 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4113 case DST__K_SRC_SETLNUM_L
:
4114 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4115 curr_srec
->line
= data
;
4117 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4120 case DST__K_SRC_SETLNUM_W
:
4121 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4122 curr_srec
->line
= data
;
4124 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4127 case DST__K_SRC_SETREC_L
:
4128 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4129 curr_srec
->srec
= data
;
4130 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4132 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4135 case DST__K_SRC_SETREC_W
:
4136 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4137 curr_srec
->srec
= data
;
4138 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4140 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4143 case DST__K_SRC_FORMFEED
:
4145 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4149 (*_bfd_error_handler
) (_("unknown source command %d"),
4155 src_ptr
+= cmd_length
;
4159 case DST__K_LINE_NUM
:
4160 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4162 vms_debug2 ((3, "line info\n"));
4164 while (pcl_ptr
< ptr
+ rec_length
)
4166 /* The command byte is signed so we must sign-extend it. */
4167 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4171 case DST__K_DELTA_PC_W
:
4172 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4176 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4179 case DST__K_DELTA_PC_L
:
4180 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4184 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4187 case DST__K_INCR_LINUM
:
4188 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4189 curr_linenum
+= data
;
4191 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4194 case DST__K_INCR_LINUM_W
:
4195 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4196 curr_linenum
+= data
;
4198 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4201 case DST__K_INCR_LINUM_L
:
4202 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4203 curr_linenum
+= data
;
4205 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4208 case DST__K_SET_LINUM_INCR
:
4209 (*_bfd_error_handler
)
4210 (_("DST__K_SET_LINUM_INCR not implemented"));
4214 case DST__K_SET_LINUM_INCR_W
:
4215 (*_bfd_error_handler
)
4216 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4220 case DST__K_RESET_LINUM_INCR
:
4221 (*_bfd_error_handler
)
4222 (_("DST__K_RESET_LINUM_INCR not implemented"));
4226 case DST__K_BEG_STMT_MODE
:
4227 (*_bfd_error_handler
)
4228 (_("DST__K_BEG_STMT_MODE not implemented"));
4232 case DST__K_END_STMT_MODE
:
4233 (*_bfd_error_handler
)
4234 (_("DST__K_END_STMT_MODE not implemented"));
4238 case DST__K_SET_LINUM_B
:
4239 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4240 curr_linenum
= data
;
4242 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4245 case DST__K_SET_LINUM
:
4246 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4247 curr_linenum
= data
;
4249 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4252 case DST__K_SET_LINUM_L
:
4253 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4254 curr_linenum
= data
;
4256 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4260 (*_bfd_error_handler
)
4261 (_("DST__K_SET_PC not implemented"));
4265 case DST__K_SET_PC_W
:
4266 (*_bfd_error_handler
)
4267 (_("DST__K_SET_PC_W not implemented"));
4271 case DST__K_SET_PC_L
:
4272 (*_bfd_error_handler
)
4273 (_("DST__K_SET_PC_L not implemented"));
4277 case DST__K_SET_STMTNUM
:
4278 (*_bfd_error_handler
)
4279 (_("DST__K_SET_STMTNUM not implemented"));
4284 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4287 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4291 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4294 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4298 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4301 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4304 case DST__K_SET_ABS_PC
:
4305 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4308 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4317 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4318 (unsigned long)curr_pc
, curr_linenum
));
4322 (*_bfd_error_handler
) (_("unknown line command %d"),
4329 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4331 || cmd
== DST__K_DELTA_PC_L
4332 || cmd
== DST__K_DELTA_PC_W
)
4334 line
= (struct lineinfo
*)
4335 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4336 line
->address
= curr_pc
;
4337 line
->line
= curr_linenum
;
4339 curr_line
->next
= line
;
4342 prev_linum
= curr_linenum
;
4344 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4345 (unsigned long)curr_pc
, curr_linenum
));
4348 pcl_ptr
+= cmd_length
;
4352 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4353 vms_debug2 ((3, "undocumented type 0x17\n"));
4357 vms_debug2 ((3, "ignoring record\n"));
4365 /* Finalize tables with EOL marker. */
4366 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4367 srec
->line
= (unsigned int) -1;
4368 srec
->srec
= (unsigned int) -1;
4369 curr_srec
->next
= srec
;
4371 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4372 line
->line
= (unsigned int) -1;
4373 line
->address
= (bfd_vma
) -1;
4374 curr_line
->next
= line
;
4376 /* Advertise that this module has been parsed. This is needed
4377 because parsing can be either performed at module creation
4378 or deferred until debug info is consumed. */
4379 SET_MODULE_PARSED (module
);
4382 /* Build the list of modules for the specified BFD. */
4384 static struct module
*
4385 build_module_list (bfd
*abfd
)
4387 struct module
*module
, *list
= NULL
;
4390 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4392 /* We have a DMT section so this must be an image. Parse the
4393 section and build the list of modules. This is sufficient
4394 since we can compute the start address and the end address
4395 of every module from the section contents. */
4396 bfd_size_type size
= bfd_get_section_size (dmt
);
4397 unsigned char *ptr
, *end
;
4399 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4403 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4406 vms_debug2 ((2, "DMT\n"));
4412 /* Each header declares a module with its start offset and size
4413 of debug info in the DST section, as well as the count of
4414 program sections (i.e. address spans) it contains. */
4415 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4416 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4417 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4418 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4420 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4421 modbeg
, msize
, count
));
4423 /* We create a 'module' structure for each program section since
4424 we only support contiguous addresses in a 'module' structure.
4425 As a consequence, the actual debug info in the DST section is
4426 shared and can be parsed multiple times; that doesn't seem to
4427 cause problems in practice. */
4430 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4431 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4432 module
= new_module (abfd
);
4433 module
->modbeg
= modbeg
;
4434 module
->size
= msize
;
4435 module
->low
= start
;
4436 module
->high
= start
+ length
;
4437 module
->next
= list
;
4439 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4441 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4448 /* We don't have a DMT section so this must be an object. Parse
4449 the module right now in order to compute its start address and
4451 module
= new_module (abfd
);
4452 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4459 /* Calculate and return the name of the source file and the line nearest
4460 to the wanted location in the specified module. */
4463 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4464 const char **file
, const char **func
,
4467 struct funcinfo
*funcinfo
;
4468 struct lineinfo
*lineinfo
;
4469 struct srecinfo
*srecinfo
;
4470 bfd_boolean ret
= FALSE
;
4472 /* Parse this module if that was not done at module creation. */
4473 if (! IS_MODULE_PARSED (module
))
4475 unsigned int size
= module
->size
;
4476 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4477 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4479 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4480 || bfd_bread (buffer
, size
, abfd
) != size
)
4482 bfd_set_error (bfd_error_no_debug_section
);
4486 parse_module (abfd
, module
, buffer
, size
);
4490 /* Find out the function (if any) that contains the address. */
4491 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4492 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4494 *func
= funcinfo
->name
;
4499 /* Find out the source file and the line nearest to the address. */
4500 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4501 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4503 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4504 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4506 if (srecinfo
->sfile
> 0)
4508 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4509 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4513 *file
= module
->name
;
4514 *line
= lineinfo
->line
;
4525 /* Provided a BFD, a section and an offset into the section, calculate and
4526 return the name of the source file and the line nearest to the wanted
4530 _bfd_vms_find_nearest_dst_line (bfd
*abfd
, asection
*section
,
4531 asymbol
**symbols ATTRIBUTE_UNUSED
,
4532 bfd_vma offset
, const char **file
,
4533 const char **func
, unsigned int *line
)
4535 struct module
*module
;
4537 /* What address are we looking for? */
4538 bfd_vma addr
= section
->vma
+ offset
;
4544 if (PRIV (dst_section
) == NULL
|| !(abfd
->flags
& (EXEC_P
| DYNAMIC
)))
4547 if (PRIV (modules
) == NULL
)
4549 PRIV (modules
) = build_module_list (abfd
);
4550 if (PRIV (modules
) == NULL
)
4554 for (module
= PRIV (modules
); module
; module
= module
->next
)
4555 if (addr
>= module
->low
&& addr
<= module
->high
)
4556 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4561 /* Canonicalizations. */
4562 /* Set name, value, section and flags of SYM from E. */
4565 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4574 flags
= BSF_NO_FLAGS
;
4580 if (e
->flags
& EGSY__V_WEAK
)
4583 if (e
->flags
& EGSY__V_DEF
)
4585 /* Symbol definition. */
4586 flags
|= BSF_GLOBAL
;
4587 if (e
->flags
& EGSY__V_NORM
)
4588 flags
|= BSF_FUNCTION
;
4590 sec
= PRIV (sections
)[e
->section
];
4594 /* Symbol reference. */
4595 sec
= bfd_und_section_ptr
;
4600 /* A universal symbol is by definition global... */
4601 flags
|= BSF_GLOBAL
;
4603 /* ...and dynamic in shared libraries. */
4604 if (abfd
->flags
& DYNAMIC
)
4605 flags
|= BSF_DYNAMIC
;
4607 if (e
->flags
& EGSY__V_WEAK
)
4610 if (!(e
->flags
& EGSY__V_DEF
))
4613 if (e
->flags
& EGSY__V_NORM
)
4614 flags
|= BSF_FUNCTION
;
4616 value
= e
->symbol_vector
;
4618 /* Adding this offset is necessary in order for GDB to
4619 read the DWARF-2 debug info from shared libraries. */
4620 if ((abfd
->flags
& DYNAMIC
) && strstr (name
, "$DWARF2.DEBUG") != 0)
4621 value
+= PRIV (symvva
);
4623 sec
= bfd_abs_section_ptr
;
4625 /* Find containing section. */
4630 for (s
= abfd
->sections
; s
; s
= s
->next
)
4634 && !(s
->flags
& SEC_COFF_SHARED_LIBRARY
)
4635 && (s
->size
> 0 || !(e
->flags
& EGSY__V_REL
)))
4659 /* Return the number of bytes required to store a vector of pointers
4660 to asymbols for all the symbols in the BFD abfd, including a
4661 terminal NULL pointer. If there are no symbols in the BFD,
4662 then return 0. If an error occurs, return -1. */
4665 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4667 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4668 abfd
, PRIV (gsd_sym_count
)));
4670 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4673 /* Read the symbols from the BFD abfd, and fills in the vector
4674 location with pointers to the symbols and a trailing NULL.
4676 Return number of symbols read. */
4679 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4683 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4685 if (PRIV (csymbols
) == NULL
)
4687 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4688 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4690 /* Traverse table and fill symbols vector. */
4691 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4693 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4696 sym
= bfd_make_empty_symbol (abfd
);
4697 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4699 bfd_release (abfd
, PRIV (csymbols
));
4700 PRIV (csymbols
) = NULL
;
4704 PRIV (csymbols
)[i
] = sym
;
4708 if (symbols
!= NULL
)
4710 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4711 symbols
[i
] = PRIV (csymbols
)[i
];
4715 return PRIV (gsd_sym_count
);
4718 /* Read and convert relocations from ETIR. We do it once for all sections. */
4721 alpha_vms_slurp_relocs (bfd
*abfd
)
4725 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4727 /* We slurp relocs only once, for all sections. */
4728 if (PRIV (reloc_done
))
4730 PRIV (reloc_done
) = TRUE
;
4732 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4735 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4740 unsigned char *begin
;
4743 bfd_reloc_code_real_type reloc_code
;
4749 bfd_vma cur_address
;
4751 unsigned char *cur_sym
= NULL
;
4753 bfd_vma cur_addend
= 0;
4755 /* Skip non-ETIR records. */
4756 type
= _bfd_vms_get_object_record (abfd
);
4757 if (type
== EOBJ__C_EEOM
)
4759 if (type
!= EOBJ__C_ETIR
)
4762 begin
= PRIV (recrd
.rec
) + 4;
4763 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4765 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4769 cmd
= bfd_getl16 (ptr
);
4770 length
= bfd_getl16 (ptr
+ 2);
4772 cur_address
= vaddr
;
4774 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4775 _bfd_vms_etir_name (cmd
)));
4779 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4780 /* ALPHA_R_REFQUAD und_section, step 1 */
4785 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4786 cur_psidx
= bfd_getl32 (ptr
+ 4);
4787 cur_addend
= bfd_getl64 (ptr
+ 8);
4791 case ETIR__C_CTL_SETRB
:
4792 if (prev_cmd
!= ETIR__C_STA_PQ
)
4794 (*_bfd_error_handler
)
4795 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
4796 _bfd_vms_etir_name (cmd
));
4799 cur_psect
= cur_psidx
;
4805 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
4806 /* ALPHA_R_REFLONG und_section, step 2 */
4809 if (prev_cmd
!= ETIR__C_STA_GBL
)
4811 (*_bfd_error_handler
)
4812 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4813 _bfd_vms_etir_name (ETIR__C_STA_LW
));
4817 cur_addend
= bfd_getl32 (ptr
+ 4);
4821 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
4822 /* ALPHA_R_REFQUAD und_section, step 2 */
4823 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
4825 (*_bfd_error_handler
)
4826 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4827 _bfd_vms_etir_name (ETIR__C_STA_QW
));
4830 cur_addend
= bfd_getl64 (ptr
+ 4);
4834 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
4835 /* ALPHA_R_REFLONG abs_section, step 2 */
4836 /* ALPHA_R_REFLONG others, step 2 */
4837 if (prev_cmd
!= ETIR__C_OPR_ADD
4838 && prev_cmd
!= ETIR__C_STA_LW
4839 && prev_cmd
!= ETIR__C_STA_PQ
)
4841 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4842 _bfd_vms_etir_name (prev_cmd
),
4843 _bfd_vms_etir_name (ETIR__C_STO_LW
));
4846 reloc_code
= BFD_RELOC_32
;
4849 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
4850 /* ALPHA_R_REFQUAD abs_section, step 2 */
4851 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
4853 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4854 _bfd_vms_etir_name (prev_cmd
),
4855 _bfd_vms_etir_name (ETIR__C_STO_QW
));
4858 reloc_code
= BFD_RELOC_64
;
4861 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
4862 if (prev_cmd
!= ETIR__C_STA_PQ
)
4864 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4865 _bfd_vms_etir_name (prev_cmd
),
4866 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
4869 reloc_code
= BFD_RELOC_64
;
4872 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
4873 /* ALPHA_R_REFQUAD und_section, step 3 */
4874 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
4876 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4877 _bfd_vms_etir_name (prev_cmd
),
4878 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
4881 prev_cmd
= ETIR__C_OPR_ADD
;
4884 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
4885 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
4889 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
4890 reloc_code
= BFD_RELOC_64
;
4894 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
4895 reloc_code
= BFD_RELOC_32
;
4899 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
4900 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
4904 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
4905 reloc_code
= BFD_RELOC_ALPHA_NOP
;
4908 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
4909 reloc_code
= BFD_RELOC_ALPHA_BSR
;
4912 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
4913 reloc_code
= BFD_RELOC_ALPHA_LDA
;
4916 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
4917 reloc_code
= BFD_RELOC_ALPHA_BOH
;
4921 cur_sym
= ptr
+ 4 + 32;
4922 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
4923 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
4926 case ETIR__C_STO_IMM
:
4927 vaddr
+= bfd_getl32 (ptr
+ 4);
4931 (*_bfd_error_handler
) (_("Unknown reloc %s"),
4932 _bfd_vms_etir_name (cmd
));
4938 struct vms_section_data_struct
*vms_sec
;
4941 /* Get section to which the relocation applies. */
4942 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
4944 (*_bfd_error_handler
) (_("Invalid section index in ETIR"));
4947 sec
= PRIV (sections
)[cur_psect
];
4948 vms_sec
= vms_section_data (sec
);
4950 /* Allocate a reloc entry. */
4951 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
4953 if (vms_sec
->reloc_max
== 0)
4955 vms_sec
->reloc_max
= 64;
4956 sec
->relocation
= bfd_zmalloc
4957 (vms_sec
->reloc_max
* sizeof (arelent
));
4961 vms_sec
->reloc_max
*= 2;
4962 sec
->relocation
= bfd_realloc
4963 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
4966 reloc
= &sec
->relocation
[sec
->reloc_count
];
4969 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
4971 if (cur_sym
!= NULL
)
4974 unsigned int symlen
= *cur_sym
;
4977 /* Linear search. */
4982 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
4983 if (PRIV (syms
)[j
]->namelen
== symlen
4984 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
4986 sym
= &PRIV (csymbols
)[j
];
4991 (*_bfd_error_handler
) (_("Unknown symbol in command %s"),
4992 _bfd_vms_etir_name (cmd
));
4993 reloc
->sym_ptr_ptr
= NULL
;
4996 reloc
->sym_ptr_ptr
= sym
;
4998 else if (cur_psidx
>= 0)
4999 reloc
->sym_ptr_ptr
=
5000 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5002 reloc
->sym_ptr_ptr
= NULL
;
5004 reloc
->address
= cur_address
;
5005 reloc
->addend
= cur_addend
;
5007 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5016 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5021 /* Return the number of bytes required to store the relocation
5022 information associated with the given section. */
5025 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5027 alpha_vms_slurp_relocs (abfd
);
5029 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5032 /* Convert relocations from VMS (external) form into BFD internal
5033 form. Return the number of relocations. */
5036 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5037 asymbol
**symbols ATTRIBUTE_UNUSED
)
5042 if (!alpha_vms_slurp_relocs (abfd
))
5045 count
= section
->reloc_count
;
5046 tblptr
= section
->relocation
;
5049 *relptr
++ = tblptr
++;
5051 *relptr
= (arelent
*) NULL
;
5052 return section
->reloc_count
;
5055 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5057 /* How to process the various reloc types. */
5059 static bfd_reloc_status_type
5060 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5061 arelent
*reloc ATTRIBUTE_UNUSED
,
5062 asymbol
*sym ATTRIBUTE_UNUSED
,
5063 void * data ATTRIBUTE_UNUSED
,
5064 asection
*sec ATTRIBUTE_UNUSED
,
5065 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5066 char **error_message ATTRIBUTE_UNUSED
)
5069 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5070 vms_debug (2, "In section %s, symbol %s\n",
5071 sec
->name
, sym
->name
);
5072 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5073 reloc
->sym_ptr_ptr
[0]->name
,
5074 (unsigned long)reloc
->address
,
5075 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5076 vms_debug (2, "data at %p\n", data
);
5077 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5080 return bfd_reloc_ok
;
5083 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5084 from smaller values. Start with zero, widen, *then* decrement. */
5085 #define MINUS_ONE (((bfd_vma)0) - 1)
5087 static reloc_howto_type alpha_howto_table
[] =
5089 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5090 0, /* Rightshift. */
5091 0, /* Size (0 = byte, 1 = short, 2 = long). */
5093 TRUE
, /* PC relative. */
5095 complain_overflow_dont
,/* Complain_on_overflow. */
5096 reloc_nil
, /* Special_function. */
5097 "IGNORE", /* Name. */
5098 TRUE
, /* Partial_inplace. */
5099 0, /* Source mask */
5101 TRUE
), /* PC rel offset. */
5103 /* A 64 bit reference to a symbol. */
5104 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5105 0, /* Rightshift. */
5106 4, /* Size (0 = byte, 1 = short, 2 = long). */
5108 FALSE
, /* PC relative. */
5110 complain_overflow_bitfield
, /* Complain_on_overflow. */
5111 reloc_nil
, /* Special_function. */
5112 "REFQUAD", /* Name. */
5113 TRUE
, /* Partial_inplace. */
5114 MINUS_ONE
, /* Source mask. */
5115 MINUS_ONE
, /* Dest mask. */
5116 FALSE
), /* PC rel offset. */
5118 /* A 21 bit branch. The native assembler generates these for
5119 branches within the text segment, and also fills in the PC
5120 relative offset in the instruction. */
5121 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5122 2, /* Rightshift. */
5123 2, /* Size (0 = byte, 1 = short, 2 = long). */
5125 TRUE
, /* PC relative. */
5127 complain_overflow_signed
, /* Complain_on_overflow. */
5128 reloc_nil
, /* Special_function. */
5129 "BRADDR", /* Name. */
5130 TRUE
, /* Partial_inplace. */
5131 0x1fffff, /* Source mask. */
5132 0x1fffff, /* Dest mask. */
5133 FALSE
), /* PC rel offset. */
5135 /* A hint for a jump to a register. */
5136 HOWTO (ALPHA_R_HINT
, /* Type. */
5137 2, /* Rightshift. */
5138 1, /* Size (0 = byte, 1 = short, 2 = long). */
5140 TRUE
, /* PC relative. */
5142 complain_overflow_dont
,/* Complain_on_overflow. */
5143 reloc_nil
, /* Special_function. */
5145 TRUE
, /* Partial_inplace. */
5146 0x3fff, /* Source mask. */
5147 0x3fff, /* Dest mask. */
5148 FALSE
), /* PC rel offset. */
5150 /* 16 bit PC relative offset. */
5151 HOWTO (ALPHA_R_SREL16
, /* Type. */
5152 0, /* Rightshift. */
5153 1, /* Size (0 = byte, 1 = short, 2 = long). */
5155 TRUE
, /* PC relative. */
5157 complain_overflow_signed
, /* Complain_on_overflow. */
5158 reloc_nil
, /* Special_function. */
5159 "SREL16", /* Name. */
5160 TRUE
, /* Partial_inplace. */
5161 0xffff, /* Source mask. */
5162 0xffff, /* Dest mask. */
5163 FALSE
), /* PC rel offset. */
5165 /* 32 bit PC relative offset. */
5166 HOWTO (ALPHA_R_SREL32
, /* Type. */
5167 0, /* Rightshift. */
5168 2, /* Size (0 = byte, 1 = short, 2 = long). */
5170 TRUE
, /* PC relative. */
5172 complain_overflow_signed
, /* Complain_on_overflow. */
5173 reloc_nil
, /* Special_function. */
5174 "SREL32", /* Name. */
5175 TRUE
, /* Partial_inplace. */
5176 0xffffffff, /* Source mask. */
5177 0xffffffff, /* Dest mask. */
5178 FALSE
), /* PC rel offset. */
5180 /* A 64 bit PC relative offset. */
5181 HOWTO (ALPHA_R_SREL64
, /* Type. */
5182 0, /* Rightshift. */
5183 4, /* Size (0 = byte, 1 = short, 2 = long). */
5185 TRUE
, /* PC relative. */
5187 complain_overflow_signed
, /* Complain_on_overflow. */
5188 reloc_nil
, /* Special_function. */
5189 "SREL64", /* Name. */
5190 TRUE
, /* Partial_inplace. */
5191 MINUS_ONE
, /* Source mask. */
5192 MINUS_ONE
, /* Dest mask. */
5193 FALSE
), /* PC rel offset. */
5195 /* Push a value on the reloc evaluation stack. */
5196 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5197 0, /* Rightshift. */
5198 0, /* Size (0 = byte, 1 = short, 2 = long). */
5200 FALSE
, /* PC relative. */
5202 complain_overflow_dont
,/* Complain_on_overflow. */
5203 reloc_nil
, /* Special_function. */
5204 "OP_PUSH", /* Name. */
5205 FALSE
, /* Partial_inplace. */
5206 0, /* Source mask. */
5208 FALSE
), /* PC rel offset. */
5210 /* Store the value from the stack at the given address. Store it in
5211 a bitfield of size r_size starting at bit position r_offset. */
5212 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5213 0, /* Rightshift. */
5214 4, /* Size (0 = byte, 1 = short, 2 = long). */
5216 FALSE
, /* PC relative. */
5218 complain_overflow_dont
,/* Complain_on_overflow. */
5219 reloc_nil
, /* Special_function. */
5220 "OP_STORE", /* Name. */
5221 FALSE
, /* Partial_inplace. */
5222 0, /* Source mask. */
5223 MINUS_ONE
, /* Dest mask. */
5224 FALSE
), /* PC rel offset. */
5226 /* Subtract the reloc address from the value on the top of the
5227 relocation stack. */
5228 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5229 0, /* Rightshift. */
5230 0, /* Size (0 = byte, 1 = short, 2 = long). */
5232 FALSE
, /* PC relative. */
5234 complain_overflow_dont
,/* Complain_on_overflow. */
5235 reloc_nil
, /* Special_function. */
5236 "OP_PSUB", /* Name. */
5237 FALSE
, /* Partial_inplace. */
5238 0, /* Source mask. */
5240 FALSE
), /* PC rel offset. */
5242 /* Shift the value on the top of the relocation stack right by the
5244 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5245 0, /* Rightshift. */
5246 0, /* Size (0 = byte, 1 = short, 2 = long). */
5248 FALSE
, /* PC relative. */
5250 complain_overflow_dont
,/* Complain_on_overflow. */
5251 reloc_nil
, /* Special_function. */
5252 "OP_PRSHIFT", /* Name. */
5253 FALSE
, /* Partial_inplace. */
5254 0, /* Source mask. */
5256 FALSE
), /* PC rel offset. */
5258 /* Hack. Linkage is done by linker. */
5259 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5260 0, /* Rightshift. */
5261 8, /* Size (0 = byte, 1 = short, 2 = long). */
5263 FALSE
, /* PC relative. */
5265 complain_overflow_dont
,/* Complain_on_overflow. */
5266 reloc_nil
, /* Special_function. */
5267 "LINKAGE", /* Name. */
5268 FALSE
, /* Partial_inplace. */
5269 0, /* Source mask. */
5271 FALSE
), /* PC rel offset. */
5273 /* A 32 bit reference to a symbol. */
5274 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5275 0, /* Rightshift. */
5276 2, /* Size (0 = byte, 1 = short, 2 = long). */
5278 FALSE
, /* PC relative. */
5280 complain_overflow_bitfield
, /* Complain_on_overflow. */
5281 reloc_nil
, /* Special_function. */
5282 "REFLONG", /* Name. */
5283 TRUE
, /* Partial_inplace. */
5284 0xffffffff, /* Source mask. */
5285 0xffffffff, /* Dest mask. */
5286 FALSE
), /* PC rel offset. */
5288 /* A 64 bit reference to a procedure, written as 32 bit value. */
5289 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5290 0, /* Rightshift. */
5291 4, /* Size (0 = byte, 1 = short, 2 = long). */
5293 FALSE
, /* PC relative. */
5295 complain_overflow_signed
,/* Complain_on_overflow. */
5296 reloc_nil
, /* Special_function. */
5297 "CODEADDR", /* Name. */
5298 FALSE
, /* Partial_inplace. */
5299 0xffffffff, /* Source mask. */
5300 0xffffffff, /* Dest mask. */
5301 FALSE
), /* PC rel offset. */
5303 HOWTO (ALPHA_R_NOP
, /* Type. */
5304 0, /* Rightshift. */
5305 3, /* Size (0 = byte, 1 = short, 2 = long). */
5307 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5308 because the calculations for the 3 relocations are the same.
5309 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5310 TRUE
, /* PC relative. */
5312 complain_overflow_dont
,/* Complain_on_overflow. */
5313 reloc_nil
, /* Special_function. */
5315 FALSE
, /* Partial_inplace. */
5316 0xffffffff, /* Source mask. */
5317 0xffffffff, /* Dest mask. */
5318 FALSE
), /* PC rel offset. */
5320 HOWTO (ALPHA_R_BSR
, /* Type. */
5321 0, /* Rightshift. */
5322 3, /* Size (0 = byte, 1 = short, 2 = long). */
5324 TRUE
, /* PC relative. */
5326 complain_overflow_dont
,/* Complain_on_overflow. */
5327 reloc_nil
, /* Special_function. */
5329 FALSE
, /* Partial_inplace. */
5330 0xffffffff, /* Source mask. */
5331 0xffffffff, /* Dest mask. */
5332 FALSE
), /* PC rel offset. */
5334 HOWTO (ALPHA_R_LDA
, /* Type. */
5335 0, /* Rightshift. */
5336 3, /* Size (0 = byte, 1 = short, 2 = long). */
5338 FALSE
, /* PC relative. */
5340 complain_overflow_dont
,/* Complain_on_overflow. */
5341 reloc_nil
, /* Special_function. */
5343 FALSE
, /* Partial_inplace. */
5344 0xffffffff, /* Source mask. */
5345 0xffffffff, /* Dest mask. */
5346 FALSE
), /* PC rel offset. */
5348 HOWTO (ALPHA_R_BOH
, /* Type. */
5349 0, /* Rightshift. */
5350 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5352 TRUE
, /* PC relative. */
5354 complain_overflow_dont
,/* Complain_on_overflow. */
5355 reloc_nil
, /* Special_function. */
5357 FALSE
, /* Partial_inplace. */
5358 0xffffffff, /* Source mask. */
5359 0xffffffff, /* Dest mask. */
5360 FALSE
), /* PC rel offset. */
5363 /* Return a pointer to a howto structure which, when invoked, will perform
5364 the relocation code on data from the architecture noted. */
5366 static const struct reloc_howto_struct
*
5367 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5368 bfd_reloc_code_real_type code
)
5372 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5376 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5377 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5378 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5379 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5380 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5381 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5382 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5383 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5384 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5385 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5386 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5387 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5388 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5389 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5390 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5392 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
5395 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5396 return & alpha_howto_table
[alpha_type
];
5399 static reloc_howto_type
*
5400 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5406 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5408 if (alpha_howto_table
[i
].name
!= NULL
5409 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5410 return &alpha_howto_table
[i
];
5416 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5417 long symcount ATTRIBUTE_UNUSED
,
5418 asymbol
**usyms ATTRIBUTE_UNUSED
,
5419 long dynsymcount ATTRIBUTE_UNUSED
,
5420 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5427 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5432 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5434 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5445 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5451 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5453 value
= e
->code_value
;
5454 sec
= PRIV (sections
)[e
->code_section
];
5461 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5466 value
= e
->code_value
;
5468 /* Find containing section. */
5469 for (s
= abfd
->sections
; s
; s
= s
->next
)
5473 && !(s
->flags
& SEC_COFF_SHARED_LIBRARY
)
5474 && (s
->size
> 0 || !(e
->flags
& EGSY__V_REL
)))
5491 sname
= bfd_alloc (abfd
, l
+ 5);
5494 memcpy (sname
, name
, l
);
5495 memcpy (sname
+ l
, "..en", 5);
5502 sym
->udata
.p
= NULL
;
5511 vms_time_to_str (unsigned char *buf
)
5513 time_t t
= vms_rawtime_to_time_t (buf
);
5514 char *res
= ctime (&t
);
5517 res
= "*invalid time*";
5524 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5526 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5527 unsigned int subtype
;
5529 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5531 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5537 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5540 fprintf (file
, _("Module header\n"));
5541 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5542 fprintf (file
, _(" max record size: %u\n"),
5543 (unsigned)bfd_getl32 (mhd
->recsiz
));
5544 name
= (char *)(mhd
+ 1);
5545 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5546 name
+= name
[0] + 1;
5547 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5548 name
+= name
[0] + 1;
5549 fprintf (file
, _(" compile date : %.17s\n"), name
);
5554 fprintf (file
, _("Language Processor Name\n"));
5555 fprintf (file
, _(" language name: %.*s\n"),
5556 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5557 (char *)rec
+ sizeof (struct vms_emh_common
));
5562 fprintf (file
, _("Source Files Header\n"));
5563 fprintf (file
, _(" file: %.*s\n"),
5564 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5565 (char *)rec
+ sizeof (struct vms_emh_common
));
5570 fprintf (file
, _("Title Text Header\n"));
5571 fprintf (file
, _(" title: %.*s\n"),
5572 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5573 (char *)rec
+ sizeof (struct vms_emh_common
));
5578 fprintf (file
, _("Copyright Header\n"));
5579 fprintf (file
, _(" copyright: %.*s\n"),
5580 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5581 (char *)rec
+ sizeof (struct vms_emh_common
));
5585 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5591 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5593 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5595 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5596 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5597 (unsigned)bfd_getl32 (eeom
->total_lps
));
5598 fprintf (file
, _(" completion code: %u\n"),
5599 (unsigned)bfd_getl16 (eeom
->comcod
));
5602 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5603 fprintf (file
, _(" transfer addr psect: %u\n"),
5604 (unsigned)bfd_getl32 (eeom
->psindx
));
5605 fprintf (file
, _(" transfer address : 0x%08x\n"),
5606 (unsigned)bfd_getl32 (eeom
->tfradr
));
5611 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5613 if (flags
& EGSY__V_WEAK
)
5614 fputs (_(" WEAK"), file
);
5615 if (flags
& EGSY__V_DEF
)
5616 fputs (_(" DEF"), file
);
5617 if (flags
& EGSY__V_UNI
)
5618 fputs (_(" UNI"), file
);
5619 if (flags
& EGSY__V_REL
)
5620 fputs (_(" REL"), file
);
5621 if (flags
& EGSY__V_COMM
)
5622 fputs (_(" COMM"), file
);
5623 if (flags
& EGSY__V_VECEP
)
5624 fputs (_(" VECEP"), file
);
5625 if (flags
& EGSY__V_NORM
)
5626 fputs (_(" NORM"), file
);
5627 if (flags
& EGSY__V_QUAD_VAL
)
5628 fputs (_(" QVAL"), file
);
5632 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5634 unsigned int off
= sizeof (struct vms_egsd
);
5637 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5640 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5642 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5646 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5647 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5649 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5657 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5658 unsigned int flags
= bfd_getl16 (egps
->flags
);
5661 fprintf (file
, _("PSC - Program section definition\n"));
5662 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5663 fprintf (file
, _(" flags : 0x%04x"), flags
);
5664 if (flags
& EGPS__V_PIC
)
5665 fputs (_(" PIC"), file
);
5666 if (flags
& EGPS__V_LIB
)
5667 fputs (_(" LIB"), file
);
5668 if (flags
& EGPS__V_OVR
)
5669 fputs (_(" OVR"), file
);
5670 if (flags
& EGPS__V_REL
)
5671 fputs (_(" REL"), file
);
5672 if (flags
& EGPS__V_GBL
)
5673 fputs (_(" GBL"), file
);
5674 if (flags
& EGPS__V_SHR
)
5675 fputs (_(" SHR"), file
);
5676 if (flags
& EGPS__V_EXE
)
5677 fputs (_(" EXE"), file
);
5678 if (flags
& EGPS__V_RD
)
5679 fputs (_(" RD"), file
);
5680 if (flags
& EGPS__V_WRT
)
5681 fputs (_(" WRT"), file
);
5682 if (flags
& EGPS__V_VEC
)
5683 fputs (_(" VEC"), file
);
5684 if (flags
& EGPS__V_NOMOD
)
5685 fputs (_(" NOMOD"), file
);
5686 if (flags
& EGPS__V_COM
)
5687 fputs (_(" COM"), file
);
5688 if (flags
& EGPS__V_ALLOC_64BIT
)
5689 fputs (_(" 64B"), file
);
5691 l
= bfd_getl32 (egps
->alloc
);
5692 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5693 fprintf (file
, _(" name : %.*s\n"),
5694 egps
->namlng
, egps
->name
);
5699 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5700 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5702 if (flags
& EGSY__V_DEF
)
5704 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5706 fprintf (file
, _("SYM - Global symbol definition\n"));
5707 fprintf (file
, _(" flags: 0x%04x"), flags
);
5708 exav_bfd_print_egsy_flags (flags
, file
);
5710 fprintf (file
, _(" psect offset: 0x%08x\n"),
5711 (unsigned)bfd_getl32 (esdf
->value
));
5712 if (flags
& EGSY__V_NORM
)
5714 fprintf (file
, _(" code address: 0x%08x\n"),
5715 (unsigned)bfd_getl32 (esdf
->code_address
));
5716 fprintf (file
, _(" psect index for entry point : %u\n"),
5717 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5719 fprintf (file
, _(" psect index : %u\n"),
5720 (unsigned)bfd_getl32 (esdf
->psindx
));
5721 fprintf (file
, _(" name : %.*s\n"),
5722 esdf
->namlng
, esdf
->name
);
5726 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5728 fprintf (file
, _("SYM - Global symbol reference\n"));
5729 fprintf (file
, _(" name : %.*s\n"),
5730 esrf
->namlng
, esrf
->name
);
5736 struct vms_egst
*egst
= (struct vms_egst
*)e
;
5737 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
5739 fprintf (file
, _("SYMG - Universal symbol definition\n"));
5740 fprintf (file
, _(" flags: 0x%04x"), flags
);
5741 exav_bfd_print_egsy_flags (flags
, file
);
5743 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
5744 (unsigned)bfd_getl32 (egst
->value
));
5745 fprintf (file
, _(" entry point: 0x%08x\n"),
5746 (unsigned)bfd_getl32 (egst
->lp_1
));
5747 fprintf (file
, _(" proc descr : 0x%08x\n"),
5748 (unsigned)bfd_getl32 (egst
->lp_2
));
5749 fprintf (file
, _(" psect index: %u\n"),
5750 (unsigned)bfd_getl32 (egst
->psindx
));
5751 fprintf (file
, _(" name : %.*s\n"),
5752 egst
->namlng
, egst
->name
);
5757 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
5758 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
5760 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
5761 fprintf (file
, _(" flags: 0x%04x"), flags
);
5762 exav_bfd_print_egsy_flags (flags
, file
);
5764 fprintf (file
, _(" vector : 0x%08x\n"),
5765 (unsigned)bfd_getl32 (esdfv
->vector
));
5766 fprintf (file
, _(" psect offset: %u\n"),
5767 (unsigned)bfd_getl32 (esdfv
->value
));
5768 fprintf (file
, _(" psect index : %u\n"),
5769 (unsigned)bfd_getl32 (esdfv
->psindx
));
5770 fprintf (file
, _(" name : %.*s\n"),
5771 esdfv
->namlng
, esdfv
->name
);
5776 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
5777 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
5779 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
5780 fprintf (file
, _(" flags: 0x%04x"), flags
);
5781 exav_bfd_print_egsy_flags (flags
, file
);
5783 fprintf (file
, _(" version mask: 0x%08x\n"),
5784 (unsigned)bfd_getl32 (esdfm
->version_mask
));
5785 fprintf (file
, _(" psect offset: %u\n"),
5786 (unsigned)bfd_getl32 (esdfm
->value
));
5787 fprintf (file
, _(" psect index : %u\n"),
5788 (unsigned)bfd_getl32 (esdfm
->psindx
));
5789 fprintf (file
, _(" name : %.*s\n"),
5790 esdfm
->namlng
, esdfm
->name
);
5794 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
5802 evax_bfd_print_hex (FILE *file
, const char *pfx
,
5803 const unsigned char *buf
, unsigned int len
)
5809 for (i
= 0; i
< len
; i
++)
5813 fprintf (file
, " %02x", buf
[i
]);
5826 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
5828 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
5829 (unsigned)bfd_getl32 (buf
),
5830 (unsigned)bfd_getl32 (buf
+ 16));
5831 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
5832 (unsigned)bfd_getl32 (buf
+ 4),
5833 (unsigned)bfd_getl32 (buf
+ 12),
5834 (unsigned)bfd_getl32 (buf
+ 8));
5835 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
5836 (unsigned)bfd_getl32 (buf
+ 20),
5837 (unsigned)bfd_getl32 (buf
+ 28),
5838 (unsigned)bfd_getl32 (buf
+ 24));
5840 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
5841 (unsigned)bfd_getl32 (buf
+ 32),
5842 (unsigned)bfd_getl32 (buf
+ 40),
5843 (unsigned)bfd_getl32 (buf
+ 36));
5845 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
5849 evax_bfd_print_etir (FILE *file
, const char *name
,
5850 unsigned char *rec
, unsigned int rec_len
)
5852 unsigned int off
= sizeof (struct vms_egsd
);
5853 unsigned int sec_len
;
5855 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
5856 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
5857 (unsigned)sizeof (struct vms_eobjrec
));
5859 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
5861 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
5866 type
= bfd_getl16 (etir
->rectyp
);
5867 size
= bfd_getl16 (etir
->size
);
5868 buf
= rec
+ off
+ sizeof (struct vms_etir
);
5870 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
5873 case ETIR__C_STA_GBL
:
5874 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
5877 case ETIR__C_STA_LW
:
5878 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
5879 (unsigned)bfd_getl32 (buf
));
5881 case ETIR__C_STA_QW
:
5882 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
5883 (unsigned)bfd_getl32 (buf
+ 4),
5884 (unsigned)bfd_getl32 (buf
+ 0));
5886 case ETIR__C_STA_PQ
:
5887 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
5888 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
5889 (unsigned)bfd_getl32 (buf
+ 0),
5890 (unsigned)bfd_getl32 (buf
+ 8),
5891 (unsigned)bfd_getl32 (buf
+ 4));
5893 case ETIR__C_STA_LI
:
5894 fprintf (file
, _("STA_LI (stack literal)\n"));
5896 case ETIR__C_STA_MOD
:
5897 fprintf (file
, _("STA_MOD (stack module)\n"));
5899 case ETIR__C_STA_CKARG
:
5900 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
5904 fprintf (file
, _("STO_B (store byte)\n"));
5907 fprintf (file
, _("STO_W (store word)\n"));
5909 case ETIR__C_STO_LW
:
5910 fprintf (file
, _("STO_LW (store longword)\n"));
5912 case ETIR__C_STO_QW
:
5913 fprintf (file
, _("STO_QW (store quadword)\n"));
5915 case ETIR__C_STO_IMMR
:
5917 unsigned int len
= bfd_getl32 (buf
);
5919 _("STO_IMMR (store immediate repeat) %u bytes\n"),
5921 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
5925 case ETIR__C_STO_GBL
:
5926 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
5929 case ETIR__C_STO_CA
:
5930 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
5933 case ETIR__C_STO_RB
:
5934 fprintf (file
, _("STO_RB (store relative branch)\n"));
5936 case ETIR__C_STO_AB
:
5937 fprintf (file
, _("STO_AB (store absolute branch)\n"));
5939 case ETIR__C_STO_OFF
:
5940 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
5942 case ETIR__C_STO_IMM
:
5944 unsigned int len
= bfd_getl32 (buf
);
5946 _("STO_IMM (store immediate) %u bytes\n"),
5948 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
5952 case ETIR__C_STO_LP_PSB
:
5953 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
5955 case ETIR__C_STO_HINT_GBL
:
5956 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
5958 case ETIR__C_STO_HINT_PS
:
5959 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
5962 case ETIR__C_OPR_NOP
:
5963 fprintf (file
, _("OPR_NOP (no-operation)\n"));
5965 case ETIR__C_OPR_ADD
:
5966 fprintf (file
, _("OPR_ADD (add)\n"));
5968 case ETIR__C_OPR_SUB
:
5969 fprintf (file
, _("OPR_SUB (substract)\n"));
5971 case ETIR__C_OPR_MUL
:
5972 fprintf (file
, _("OPR_MUL (multiply)\n"));
5974 case ETIR__C_OPR_DIV
:
5975 fprintf (file
, _("OPR_DIV (divide)\n"));
5977 case ETIR__C_OPR_AND
:
5978 fprintf (file
, _("OPR_AND (logical and)\n"));
5980 case ETIR__C_OPR_IOR
:
5981 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
5983 case ETIR__C_OPR_EOR
:
5984 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
5986 case ETIR__C_OPR_NEG
:
5987 fprintf (file
, _("OPR_NEG (negate)\n"));
5989 case ETIR__C_OPR_COM
:
5990 fprintf (file
, _("OPR_COM (complement)\n"));
5992 case ETIR__C_OPR_INSV
:
5993 fprintf (file
, _("OPR_INSV (insert field)\n"));
5995 case ETIR__C_OPR_ASH
:
5996 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
5998 case ETIR__C_OPR_USH
:
5999 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6001 case ETIR__C_OPR_ROT
:
6002 fprintf (file
, _("OPR_ROT (rotate)\n"));
6004 case ETIR__C_OPR_SEL
:
6005 fprintf (file
, _("OPR_SEL (select)\n"));
6007 case ETIR__C_OPR_REDEF
:
6008 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6010 case ETIR__C_OPR_DFLIT
:
6011 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6014 case ETIR__C_STC_LP
:
6015 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6017 case ETIR__C_STC_LP_PSB
:
6019 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6020 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6021 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6022 buf
+= 4 + 1 + buf
[4];
6023 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6025 case ETIR__C_STC_GBL
:
6026 fprintf (file
, _("STC_GBL (store cond global)\n"));
6027 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6028 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6030 case ETIR__C_STC_GCA
:
6031 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6032 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6033 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6035 case ETIR__C_STC_PS
:
6036 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6038 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6039 (unsigned)bfd_getl32 (buf
),
6040 (unsigned)bfd_getl32 (buf
+ 4),
6041 (unsigned)bfd_getl32 (buf
+ 12),
6042 (unsigned)bfd_getl32 (buf
+ 8));
6044 case ETIR__C_STC_NOP_GBL
:
6045 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6046 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6048 case ETIR__C_STC_NOP_PS
:
6049 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6050 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6052 case ETIR__C_STC_BSR_GBL
:
6053 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6054 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6056 case ETIR__C_STC_BSR_PS
:
6057 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6058 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6060 case ETIR__C_STC_LDA_GBL
:
6061 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6062 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6064 case ETIR__C_STC_LDA_PS
:
6065 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6066 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6068 case ETIR__C_STC_BOH_GBL
:
6069 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6070 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6072 case ETIR__C_STC_BOH_PS
:
6073 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6074 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6076 case ETIR__C_STC_NBH_GBL
:
6078 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6080 case ETIR__C_STC_NBH_PS
:
6082 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6085 case ETIR__C_CTL_SETRB
:
6086 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6089 case ETIR__C_CTL_AUGRB
:
6091 unsigned int val
= bfd_getl32 (buf
);
6092 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6095 case ETIR__C_CTL_DFLOC
:
6096 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6098 case ETIR__C_CTL_STLOC
:
6099 fprintf (file
, _("CTL_STLOC (set location)\n"));
6101 case ETIR__C_CTL_STKDL
:
6102 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6105 fprintf (file
, _("*unhandled*\n"));
6113 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6115 bfd_boolean is_first
= TRUE
;
6116 bfd_boolean has_records
= FALSE
;
6120 unsigned int rec_len
;
6121 unsigned int pad_len
;
6123 unsigned int hdr_size
;
6128 unsigned char buf
[6];
6133 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6135 fprintf (file
, _("cannot read GST record length\n"));
6138 rec_len
= bfd_getl16 (buf
+ 0);
6139 if (rec_len
== bfd_getl16 (buf
+ 4)
6140 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6142 /* The format is raw: record-size, type, record-size. */
6144 pad_len
= (rec_len
+ 1) & ~1U;
6147 else if (rec_len
== EOBJ__C_EMH
)
6149 has_records
= FALSE
;
6150 pad_len
= bfd_getl16 (buf
+ 2);
6156 fprintf (file
, _("cannot find EMH in first GST record\n"));
6159 rec
= bfd_malloc (pad_len
);
6160 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6164 unsigned int rec_len2
= 0;
6165 unsigned char hdr
[4];
6169 unsigned char buf_len
[2];
6171 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6172 != sizeof (buf_len
))
6174 fprintf (file
, _("cannot read GST record length\n"));
6177 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6180 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6182 fprintf (file
, _("cannot read GST record header\n"));
6185 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6187 pad_len
= (rec_len
+ 1) & ~1U;
6190 rec
= bfd_malloc (pad_len
);
6191 memcpy (rec
, hdr
, sizeof (hdr
));
6192 hdr_size
= sizeof (hdr
);
6193 if (has_records
&& rec_len2
!= rec_len
)
6195 fprintf (file
, _(" corrupted GST\n"));
6200 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6201 != pad_len
- hdr_size
)
6203 fprintf (file
, _("cannot read GST record\n"));
6207 type
= (unsigned)bfd_getl16 (rec
);
6212 evax_bfd_print_emh (file
, rec
, rec_len
);
6215 evax_bfd_print_egsd (file
, rec
, rec_len
);
6218 evax_bfd_print_eeom (file
, rec
, rec_len
);
6223 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6226 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6229 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6232 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6240 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6241 unsigned int stride
)
6249 count
= bfd_getl32 (rel
+ 0);
6253 base
= bfd_getl32 (rel
+ 4);
6255 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6259 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6265 val
= bfd_getl32 (rel
);
6268 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6270 for (k
= 0; k
< 32; k
++)
6275 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6290 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6297 count
= bfd_getl32 (rel
+ 0);
6300 fprintf (file
, _(" image %u (%u entries)\n"),
6301 (unsigned)bfd_getl32 (rel
+ 4), count
);
6303 for (j
= 0; j
< count
; j
++)
6305 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6306 (unsigned)bfd_getl32 (rel
+ 0),
6307 (unsigned)bfd_getl32 (rel
+ 4));
6314 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6323 count
= bfd_getl32 (rel
+ 0);
6326 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6327 (unsigned)bfd_getl32 (rel
+ 4), count
);
6329 for (j
= 0; j
< count
; j
++)
6333 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6348 evax_bfd_print_indent (int indent
, FILE *file
)
6350 for (; indent
; indent
--)
6355 evax_bfd_get_dsc_name (unsigned int v
)
6359 case DSC__K_DTYPE_Z
:
6360 return "Z (Unspecified)";
6361 case DSC__K_DTYPE_V
:
6363 case DSC__K_DTYPE_BU
:
6364 return "BU (Byte logical)";
6365 case DSC__K_DTYPE_WU
:
6366 return "WU (Word logical)";
6367 case DSC__K_DTYPE_LU
:
6368 return "LU (Longword logical)";
6369 case DSC__K_DTYPE_QU
:
6370 return "QU (Quadword logical)";
6371 case DSC__K_DTYPE_B
:
6372 return "B (Byte integer)";
6373 case DSC__K_DTYPE_W
:
6374 return "W (Word integer)";
6375 case DSC__K_DTYPE_L
:
6376 return "L (Longword integer)";
6377 case DSC__K_DTYPE_Q
:
6378 return "Q (Quadword integer)";
6379 case DSC__K_DTYPE_F
:
6380 return "F (Single-precision floating)";
6381 case DSC__K_DTYPE_D
:
6382 return "D (Double-precision floating)";
6383 case DSC__K_DTYPE_FC
:
6384 return "FC (Complex)";
6385 case DSC__K_DTYPE_DC
:
6386 return "DC (Double-precision Complex)";
6387 case DSC__K_DTYPE_T
:
6388 return "T (ASCII text string)";
6389 case DSC__K_DTYPE_NU
:
6390 return "NU (Numeric string, unsigned)";
6391 case DSC__K_DTYPE_NL
:
6392 return "NL (Numeric string, left separate sign)";
6393 case DSC__K_DTYPE_NLO
:
6394 return "NLO (Numeric string, left overpunched sign)";
6395 case DSC__K_DTYPE_NR
:
6396 return "NR (Numeric string, right separate sign)";
6397 case DSC__K_DTYPE_NRO
:
6398 return "NRO (Numeric string, right overpunched sig)";
6399 case DSC__K_DTYPE_NZ
:
6400 return "NZ (Numeric string, zoned sign)";
6401 case DSC__K_DTYPE_P
:
6402 return "P (Packed decimal string)";
6403 case DSC__K_DTYPE_ZI
:
6404 return "ZI (Sequence of instructions)";
6405 case DSC__K_DTYPE_ZEM
:
6406 return "ZEM (Procedure entry mask)";
6407 case DSC__K_DTYPE_DSC
:
6408 return "DSC (Descriptor, used for arrays of dyn strings)";
6409 case DSC__K_DTYPE_OU
:
6410 return "OU (Octaword logical)";
6411 case DSC__K_DTYPE_O
:
6412 return "O (Octaword integer)";
6413 case DSC__K_DTYPE_G
:
6414 return "G (Double precision G floating, 64 bit)";
6415 case DSC__K_DTYPE_H
:
6416 return "H (Quadruple precision floating, 128 bit)";
6417 case DSC__K_DTYPE_GC
:
6418 return "GC (Double precision complex, G floating)";
6419 case DSC__K_DTYPE_HC
:
6420 return "HC (Quadruple precision complex, H floating)";
6421 case DSC__K_DTYPE_CIT
:
6422 return "CIT (COBOL intermediate temporary)";
6423 case DSC__K_DTYPE_BPV
:
6424 return "BPV (Bound Procedure Value)";
6425 case DSC__K_DTYPE_BLV
:
6426 return "BLV (Bound Label Value)";
6427 case DSC__K_DTYPE_VU
:
6428 return "VU (Bit Unaligned)";
6429 case DSC__K_DTYPE_ADT
:
6430 return "ADT (Absolute Date-Time)";
6431 case DSC__K_DTYPE_VT
:
6432 return "VT (Varying Text)";
6433 case DSC__K_DTYPE_T2
:
6434 return "T2 (16-bit char)";
6435 case DSC__K_DTYPE_VT2
:
6436 return "VT2 (16-bit varying char)";
6438 return "?? (unknown)";
6443 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6445 unsigned char bclass
= buf
[3];
6446 unsigned char dtype
= buf
[2];
6447 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6448 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6450 evax_bfd_print_indent (indent
, file
);
6452 if (len
== 1 && pointer
== 0xffffffffUL
)
6455 fprintf (file
, _("64 bits *unhandled*\n"));
6459 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6460 bclass
, dtype
, len
, pointer
);
6463 case DSC__K_CLASS_NCA
:
6465 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6467 const unsigned char *b
;
6469 evax_bfd_print_indent (indent
, file
);
6470 fprintf (file
, _("non-contiguous array of %s\n"),
6471 evax_bfd_get_dsc_name (dsc
->dtype
));
6472 evax_bfd_print_indent (indent
+ 1, file
);
6474 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6475 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6476 evax_bfd_print_indent (indent
+ 1, file
);
6478 _("arsize: %u, a0: 0x%08x\n"),
6479 (unsigned)bfd_getl32 (dsc
->arsize
),
6480 (unsigned)bfd_getl32 (dsc
->a0
));
6481 evax_bfd_print_indent (indent
+ 1, file
);
6482 fprintf (file
, _("Strides:\n"));
6483 b
= buf
+ sizeof (*dsc
);
6484 for (i
= 0; i
< dsc
->dimct
; i
++)
6486 evax_bfd_print_indent (indent
+ 2, file
);
6487 fprintf (file
, _("[%u]: %u\n"), i
+ 1,
6488 (unsigned)bfd_getl32 (b
));
6491 evax_bfd_print_indent (indent
+ 1, file
);
6492 fprintf (file
, _("Bounds:\n"));
6493 b
= buf
+ sizeof (*dsc
);
6494 for (i
= 0; i
< dsc
->dimct
; i
++)
6496 evax_bfd_print_indent (indent
+ 2, file
);
6497 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6498 (unsigned)bfd_getl32 (b
+ 0),
6499 (unsigned)bfd_getl32 (b
+ 4));
6504 case DSC__K_CLASS_UBS
:
6506 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6508 evax_bfd_print_indent (indent
, file
);
6509 fprintf (file
, _("unaligned bit-string of %s\n"),
6510 evax_bfd_get_dsc_name (ubs
->dtype
));
6511 evax_bfd_print_indent (indent
+ 1, file
);
6513 _("base: %u, pos: %u\n"),
6514 (unsigned)bfd_getl32 (ubs
->base
),
6515 (unsigned)bfd_getl32 (ubs
->pos
));
6519 fprintf (file
, _("*unhandled*\n"));
6526 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6528 unsigned int vflags
= buf
[0];
6529 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6530 unsigned int len
= 5;
6532 evax_bfd_print_indent (indent
, file
);
6533 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6538 case DST__K_VFLAGS_NOVAL
:
6539 fprintf (file
, _("(no value)\n"));
6541 case DST__K_VFLAGS_NOTACTIVE
:
6542 fprintf (file
, _("(not active)\n"));
6544 case DST__K_VFLAGS_UNALLOC
:
6545 fprintf (file
, _("(not allocated)\n"));
6547 case DST__K_VFLAGS_DSC
:
6548 fprintf (file
, _("(descriptor)\n"));
6549 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6551 case DST__K_VFLAGS_TVS
:
6552 fprintf (file
, _("(trailing value)\n"));
6554 case DST__K_VS_FOLLOWS
:
6555 fprintf (file
, _("(value spec follows)\n"));
6557 case DST__K_VFLAGS_BITOFFS
:
6558 fprintf (file
, _("(at bit offset %u)\n"), value
);
6561 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6562 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6563 vflags
& DST__K_DISP
? 1 : 0,
6564 vflags
& DST__K_INDIR
? 1 : 0);
6565 switch (vflags
& DST__K_VALKIND_MASK
)
6567 case DST__K_VALKIND_LITERAL
:
6568 fputs (_("literal"), file
);
6570 case DST__K_VALKIND_ADDR
:
6571 fputs (_("address"), file
);
6573 case DST__K_VALKIND_DESC
:
6574 fputs (_("desc"), file
);
6576 case DST__K_VALKIND_REG
:
6577 fputs (_("reg"), file
);
6580 fputs (")\n", file
);
6587 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6589 unsigned char kind
= buf
[2];
6590 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6592 evax_bfd_print_indent (indent
, file
);
6593 fprintf (file
, ("len: %2u, kind: %2u "), len
, kind
);
6597 case DST__K_TS_ATOM
:
6598 fprintf (file
, ("atomic, type=0x%02x %s\n"),
6599 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6602 fprintf (file
, ("indirect, defined at 0x%08x\n"),
6603 (unsigned)bfd_getl32 (buf
));
6605 case DST__K_TS_TPTR
:
6606 fprintf (file
, ("typed pointer\n"));
6607 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6610 fprintf (file
, ("pointer\n"));
6612 case DST__K_TS_ARRAY
:
6614 const unsigned char *vs
;
6615 unsigned int vec_len
;
6618 fprintf (file
, ("array, dim: %u, bitmap: "), buf
[0]);
6619 vec_len
= (buf
[0] + 1 + 7) / 8;
6620 for (i
= 0; i
< vec_len
; i
++)
6621 fprintf (file
, " %02x", buf
[i
+ 1]);
6623 vs
= buf
+ 1 + vec_len
;
6624 evax_bfd_print_indent (indent
, file
);
6625 fprintf (file
, ("array descriptor:\n"));
6626 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6627 for (i
= 0; i
< buf
[0] + 1U; i
++)
6628 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6630 evax_bfd_print_indent (indent
, file
);
6632 fprintf (file
, ("type spec for element:\n"));
6634 fprintf (file
, ("type spec for subscript %u:\n"), i
);
6635 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6636 vs
+= bfd_getl16 (vs
);
6641 fprintf (file
, ("*unhandled*\n"));
6646 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6648 unsigned int off
= 0;
6649 unsigned int pc
= 0;
6650 unsigned int line
= 0;
6652 fprintf (file
, _("Debug symbol table:\n"));
6654 while (dst_size
> 0)
6656 struct vms_dst_header dsth
;
6661 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6663 fprintf (file
, _("cannot read DST header\n"));
6666 len
= bfd_getl16 (dsth
.length
);
6667 type
= bfd_getl16 (dsth
.type
);
6668 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
6678 len
-= sizeof (dsth
);
6679 buf
= bfd_malloc (len
);
6680 if (bfd_bread (buf
, len
, abfd
) != len
)
6682 fprintf (file
, _("cannot read DST symbol\n"));
6687 case DSC__K_DTYPE_V
:
6688 case DSC__K_DTYPE_BU
:
6689 case DSC__K_DTYPE_WU
:
6690 case DSC__K_DTYPE_LU
:
6691 case DSC__K_DTYPE_QU
:
6692 case DSC__K_DTYPE_B
:
6693 case DSC__K_DTYPE_W
:
6694 case DSC__K_DTYPE_L
:
6695 case DSC__K_DTYPE_Q
:
6696 case DSC__K_DTYPE_F
:
6697 case DSC__K_DTYPE_D
:
6698 case DSC__K_DTYPE_FC
:
6699 case DSC__K_DTYPE_DC
:
6700 case DSC__K_DTYPE_T
:
6701 case DSC__K_DTYPE_NU
:
6702 case DSC__K_DTYPE_NL
:
6703 case DSC__K_DTYPE_NLO
:
6704 case DSC__K_DTYPE_NR
:
6705 case DSC__K_DTYPE_NRO
:
6706 case DSC__K_DTYPE_NZ
:
6707 case DSC__K_DTYPE_P
:
6708 case DSC__K_DTYPE_ZI
:
6709 case DSC__K_DTYPE_ZEM
:
6710 case DSC__K_DTYPE_DSC
:
6711 case DSC__K_DTYPE_OU
:
6712 case DSC__K_DTYPE_O
:
6713 case DSC__K_DTYPE_G
:
6714 case DSC__K_DTYPE_H
:
6715 case DSC__K_DTYPE_GC
:
6716 case DSC__K_DTYPE_HC
:
6717 case DSC__K_DTYPE_CIT
:
6718 case DSC__K_DTYPE_BPV
:
6719 case DSC__K_DTYPE_BLV
:
6720 case DSC__K_DTYPE_VU
:
6721 case DSC__K_DTYPE_ADT
:
6722 case DSC__K_DTYPE_VT
:
6723 case DSC__K_DTYPE_T2
:
6724 case DSC__K_DTYPE_VT2
:
6725 fprintf (file
, _("standard data: %s\n"),
6726 evax_bfd_get_dsc_name (type
));
6727 evax_bfd_print_valspec (buf
, 4, file
);
6728 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
6732 struct vms_dst_modbeg
*dst
= (void *)buf
;
6733 const char *name
= (const char *)buf
+ sizeof (*dst
);
6735 fprintf (file
, _("modbeg\n"));
6736 fprintf (file
, _(" flags: %d, language: %u, "
6737 "major: %u, minor: %u\n"),
6739 (unsigned)bfd_getl32 (dst
->language
),
6740 (unsigned)bfd_getl16 (dst
->major
),
6741 (unsigned)bfd_getl16 (dst
->minor
));
6742 fprintf (file
, _(" module name: %.*s\n"),
6744 name
+= name
[0] + 1;
6745 fprintf (file
, _(" compiler : %.*s\n"),
6750 fprintf (file
, _("modend\n"));
6754 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
6755 const char *name
= (const char *)buf
+ sizeof (*dst
);
6757 fputs (_("rtnbeg\n"), file
);
6758 fprintf (file
, _(" flags: %u, address: 0x%08x, "
6759 "pd-address: 0x%08x\n"),
6761 (unsigned)bfd_getl32 (dst
->address
),
6762 (unsigned)bfd_getl32 (dst
->pd_address
));
6763 fprintf (file
, _(" routine name: %.*s\n"),
6769 struct vms_dst_rtnend
*dst
= (void *)buf
;
6771 fprintf (file
, _("rtnend: size 0x%08x\n"),
6772 (unsigned)bfd_getl32 (dst
->size
));
6777 struct vms_dst_prolog
*dst
= (void *)buf
;
6779 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
6780 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
6785 struct vms_dst_epilog
*dst
= (void *)buf
;
6787 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
6788 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
6793 struct vms_dst_blkbeg
*dst
= (void *)buf
;
6794 const char *name
= (const char *)buf
+ sizeof (*dst
);
6796 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6797 (unsigned)bfd_getl32 (dst
->address
),
6803 struct vms_dst_blkend
*dst
= (void *)buf
;
6805 fprintf (file
, _("blkend: size: 0x%08x\n"),
6806 (unsigned)bfd_getl32 (dst
->size
));
6809 case DST__K_TYPSPEC
:
6811 fprintf (file
, _("typspec (len: %u)\n"), len
);
6812 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
6813 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
6818 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
6819 evax_bfd_print_valspec (buf
, 4, file
);
6824 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
6825 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
6827 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
6828 evax_bfd_print_valspec (buf
, 4, file
);
6829 fprintf (file
, (" len: %u bits\n"),
6830 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
6834 fprintf (file
, _("recend\n"));
6836 case DST__K_ENUMBEG
:
6837 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
6838 buf
[0], buf
[1], buf
+ 2);
6840 case DST__K_ENUMELT
:
6841 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
6842 evax_bfd_print_valspec (buf
, 4, file
);
6844 case DST__K_ENUMEND
:
6845 fprintf (file
, _("enumend\n"));
6849 struct vms_dst_label
*lab
= (void *)buf
;
6850 fprintf (file
, ("label, name: %.*s\n"),
6851 lab
->name
[0], lab
->name
+ 1);
6852 fprintf (file
, (" address: 0x%08x\n"),
6853 (unsigned)bfd_getl32 (lab
->value
));
6856 case DST__K_DIS_RANGE
:
6858 unsigned int cnt
= bfd_getl32 (buf
);
6859 unsigned char *rng
= buf
+ 4;
6862 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
6863 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
6864 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
6865 (unsigned)bfd_getl32 (rng
),
6866 (unsigned)bfd_getl32 (rng
+ 4));
6870 case DST__K_LINE_NUM
:
6872 unsigned char *buf_orig
= buf
;
6874 fprintf (file
, _("line num (len: %u)\n"), len
);
6879 unsigned char cmdlen
;
6889 case DST__K_DELTA_PC_W
:
6890 val
= bfd_getl16 (buf
+ 1);
6891 fprintf (file
, _("delta_pc_w %u\n"), val
);
6896 case DST__K_INCR_LINUM
:
6898 fprintf (file
, _("incr_linum: +%u\n"), val
);
6902 case DST__K_INCR_LINUM_W
:
6903 val
= bfd_getl16 (buf
+ 1);
6904 fprintf (file
, _("incr_linum: +%u\n"), val
);
6908 case DST__K_SET_LINUM
:
6909 line
= (unsigned)bfd_getl16 (buf
+ 1);
6910 fprintf (file
, _("set_line_num %u\n"), line
);
6913 case DST__K_SET_LINUM_B
:
6915 fprintf (file
, _("set_line_num_b %u\n"), line
);
6918 case DST__K_SET_LINUM_L
:
6919 line
= (unsigned)bfd_getl32 (buf
+ 1);
6920 fprintf (file
, _("set_line_num_l %u\n"), line
);
6923 case DST__K_SET_ABS_PC
:
6924 pc
= (unsigned)bfd_getl32 (buf
+ 1);
6925 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
6928 case DST__K_DELTA_PC_L
:
6929 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
6930 (unsigned)bfd_getl32 (buf
+ 1));
6934 fprintf (file
, _("term: 0x%02x"), buf
[1]);
6936 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
6940 val
= bfd_getl16 (buf
+ 1);
6941 fprintf (file
, _("term_w: 0x%04x"), val
);
6943 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
6949 fprintf (file
, _("delta pc +%-4d"), -cmd
);
6950 line
++; /* FIXME: curr increment. */
6952 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
6957 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
6970 unsigned char *buf_orig
= buf
;
6972 fprintf (file
, _("source (len: %u)\n"), len
);
6976 signed char cmd
= buf
[0];
6977 unsigned char cmdlen
= 0;
6981 case DST__K_SRC_DECLFILE
:
6983 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
6986 fprintf (file
, _(" declfile: len: %u, flags: %u, "
6988 src
->length
, src
->flags
,
6989 (unsigned)bfd_getl16 (src
->fileid
));
6990 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
6991 "ebk: 0x%08x, ffb: 0x%04x, "
6993 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
6994 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
6995 (unsigned)bfd_getl32 (src
->rms_ebk
),
6996 (unsigned)bfd_getl16 (src
->rms_ffb
),
6998 name
= (const char *)buf
+ 1 + sizeof (*src
);
6999 fprintf (file
, _(" filename : %.*s\n"),
7001 name
+= name
[0] + 1;
7002 fprintf (file
, _(" module name: %.*s\n"),
7004 cmdlen
= 2 + src
->length
;
7007 case DST__K_SRC_SETFILE
:
7008 fprintf (file
, _(" setfile %u\n"),
7009 (unsigned)bfd_getl16 (buf
+ 1));
7012 case DST__K_SRC_SETREC_W
:
7013 fprintf (file
, _(" setrec %u\n"),
7014 (unsigned)bfd_getl16 (buf
+ 1));
7017 case DST__K_SRC_SETREC_L
:
7018 fprintf (file
, _(" setrec %u\n"),
7019 (unsigned)bfd_getl32 (buf
+ 1));
7022 case DST__K_SRC_SETLNUM_W
:
7023 fprintf (file
, _(" setlnum %u\n"),
7024 (unsigned)bfd_getl16 (buf
+ 1));
7027 case DST__K_SRC_SETLNUM_L
:
7028 fprintf (file
, _(" setlnum %u\n"),
7029 (unsigned)bfd_getl32 (buf
+ 1));
7032 case DST__K_SRC_DEFLINES_W
:
7033 fprintf (file
, _(" deflines %u\n"),
7034 (unsigned)bfd_getl16 (buf
+ 1));
7037 case DST__K_SRC_DEFLINES_B
:
7038 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7041 case DST__K_SRC_FORMFEED
:
7042 fprintf (file
, _(" formfeed\n"));
7046 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7058 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7066 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7068 struct vms_eihd eihd
;
7071 unsigned int eiha_off
;
7072 unsigned int eihi_off
;
7073 unsigned int eihs_off
;
7074 unsigned int eisd_off
;
7075 unsigned int eihef_off
= 0;
7076 unsigned int eihnp_off
= 0;
7077 unsigned int dmt_vbn
= 0;
7078 unsigned int dmt_size
= 0;
7079 unsigned int dst_vbn
= 0;
7080 unsigned int dst_size
= 0;
7081 unsigned int gst_vbn
= 0;
7082 unsigned int gst_size
= 0;
7083 unsigned int eiaf_vbn
= 0;
7084 unsigned int eiaf_size
= 0;
7085 unsigned int eihvn_off
;
7087 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7088 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7090 fprintf (file
, _("cannot read EIHD\n"));
7093 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7094 (unsigned)bfd_getl32 (eihd
.size
),
7095 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7096 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7097 (unsigned)bfd_getl32 (eihd
.majorid
),
7098 (unsigned)bfd_getl32 (eihd
.minorid
));
7100 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7104 name
= _("executable");
7107 name
= _("linkable image");
7110 name
= _("unknown");
7113 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7115 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7118 case EIHD__C_NATIVE
:
7125 name
= _("unknown");
7128 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7130 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7131 eiha_off
= bfd_getl32 (eihd
.activoff
);
7132 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7133 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7134 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7135 "imgid: %u, patch: %u\n"),
7136 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7137 (unsigned)bfd_getl32 (eihd
.patchoff
));
7138 fprintf (file
, _(" fixup info rva: "));
7139 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7140 fprintf (file
, _(", symbol vector rva: "));
7141 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7142 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7143 fprintf (file
, _("\n"
7144 " version array off: %u\n"),
7147 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7148 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7149 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7150 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7151 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7152 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7153 fprintf (file
, _(" linker flags: %08x:"), val
);
7154 if (val
& EIHD__M_LNKDEBUG
)
7155 fprintf (file
, " LNKDEBUG");
7156 if (val
& EIHD__M_LNKNOTFR
)
7157 fprintf (file
, " LNKNOTFR");
7158 if (val
& EIHD__M_NOP0BUFS
)
7159 fprintf (file
, " NOP0BUFS");
7160 if (val
& EIHD__M_PICIMG
)
7161 fprintf (file
, " PICIMG");
7162 if (val
& EIHD__M_P0IMAGE
)
7163 fprintf (file
, " P0IMAGE");
7164 if (val
& EIHD__M_DBGDMT
)
7165 fprintf (file
, " DBGDMT");
7166 if (val
& EIHD__M_INISHR
)
7167 fprintf (file
, " INISHR");
7168 if (val
& EIHD__M_XLATED
)
7169 fprintf (file
, " XLATED");
7170 if (val
& EIHD__M_BIND_CODE_SEC
)
7171 fprintf (file
, " BIND_CODE_SEC");
7172 if (val
& EIHD__M_BIND_DATA_SEC
)
7173 fprintf (file
, " BIND_DATA_SEC");
7174 if (val
& EIHD__M_MKTHREADS
)
7175 fprintf (file
, " MKTHREADS");
7176 if (val
& EIHD__M_UPCALLS
)
7177 fprintf (file
, " UPCALLS");
7178 if (val
& EIHD__M_OMV_READY
)
7179 fprintf (file
, " OMV_READY");
7180 if (val
& EIHD__M_EXT_BIND_SECT
)
7181 fprintf (file
, " EXT_BIND_SECT");
7182 fprintf (file
, "\n");
7183 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7184 "match ctrl: %u, symvect_size: %u\n"),
7185 (unsigned)bfd_getl32 (eihd
.ident
),
7186 (unsigned)bfd_getl32 (eihd
.sysver
),
7188 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7189 fprintf (file
, _(" BPAGE: %u"),
7190 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7191 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7193 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7194 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7195 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7196 eihef_off
, eihnp_off
);
7198 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7202 struct vms_eihvn eihvn
;
7206 fprintf (file
, _("system version array information:\n"));
7207 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7208 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7210 fprintf (file
, _("cannot read EIHVN header\n"));
7213 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7214 for (j
= 0; j
< 32; j
++)
7215 if (mask
& (1 << j
))
7217 struct vms_eihvn_subversion ver
;
7218 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7220 fprintf (file
, _("cannot read EIHVN version\n"));
7223 fprintf (file
, _(" %02u "), j
);
7226 case EIHVN__BASE_IMAGE_BIT
:
7227 fputs (_("BASE_IMAGE "), file
);
7229 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7230 fputs (_("MEMORY_MANAGEMENT"), file
);
7233 fputs (_("IO "), file
);
7235 case EIHVN__FILES_VOLUMES_BIT
:
7236 fputs (_("FILES_VOLUMES "), file
);
7238 case EIHVN__PROCESS_SCHED_BIT
:
7239 fputs (_("PROCESS_SCHED "), file
);
7241 case EIHVN__SYSGEN_BIT
:
7242 fputs (_("SYSGEN "), file
);
7244 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7245 fputs (_("CLUSTERS_LOCKMGR "), file
);
7247 case EIHVN__LOGICAL_NAMES_BIT
:
7248 fputs (_("LOGICAL_NAMES "), file
);
7250 case EIHVN__SECURITY_BIT
:
7251 fputs (_("SECURITY "), file
);
7253 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7254 fputs (_("IMAGE_ACTIVATOR "), file
);
7256 case EIHVN__NETWORKS_BIT
:
7257 fputs (_("NETWORKS "), file
);
7259 case EIHVN__COUNTERS_BIT
:
7260 fputs (_("COUNTERS "), file
);
7262 case EIHVN__STABLE_BIT
:
7263 fputs (_("STABLE "), file
);
7265 case EIHVN__MISC_BIT
:
7266 fputs (_("MISC "), file
);
7268 case EIHVN__CPU_BIT
:
7269 fputs (_("CPU "), file
);
7271 case EIHVN__VOLATILE_BIT
:
7272 fputs (_("VOLATILE "), file
);
7274 case EIHVN__SHELL_BIT
:
7275 fputs (_("SHELL "), file
);
7277 case EIHVN__POSIX_BIT
:
7278 fputs (_("POSIX "), file
);
7280 case EIHVN__MULTI_PROCESSING_BIT
:
7281 fputs (_("MULTI_PROCESSING "), file
);
7283 case EIHVN__GALAXY_BIT
:
7284 fputs (_("GALAXY "), file
);
7287 fputs (_("*unknown* "), file
);
7290 fprintf (file
, _(": %u.%u\n"),
7291 (unsigned)bfd_getl16 (ver
.major
),
7292 (unsigned)bfd_getl16 (ver
.minor
));
7298 struct vms_eiha eiha
;
7300 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7301 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7303 fprintf (file
, _("cannot read EIHA\n"));
7306 fprintf (file
, _("Image activation: (size=%u)\n"),
7307 (unsigned)bfd_getl32 (eiha
.size
));
7308 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7309 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7310 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7311 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7312 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7313 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7314 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7315 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7316 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7317 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7318 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7319 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7320 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7321 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7322 (unsigned)bfd_getl32 (eiha
.inishr
));
7326 struct vms_eihi eihi
;
7328 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7329 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7331 fprintf (file
, _("cannot read EIHI\n"));
7334 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7335 (unsigned)bfd_getl32 (eihi
.majorid
),
7336 (unsigned)bfd_getl32 (eihi
.minorid
));
7337 fprintf (file
, _(" image name : %.*s\n"),
7338 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7339 fprintf (file
, _(" link time : %s\n"),
7340 vms_time_to_str (eihi
.linktime
));
7341 fprintf (file
, _(" image ident : %.*s\n"),
7342 eihi
.imgid
[0], eihi
.imgid
+ 1);
7343 fprintf (file
, _(" linker ident : %.*s\n"),
7344 eihi
.linkid
[0], eihi
.linkid
+ 1);
7345 fprintf (file
, _(" image build ident: %.*s\n"),
7346 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7350 struct vms_eihs eihs
;
7352 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7353 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7355 fprintf (file
, _("cannot read EIHS\n"));
7358 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7359 (unsigned)bfd_getl32 (eihs
.majorid
),
7360 (unsigned)bfd_getl32 (eihs
.minorid
));
7361 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7362 dst_size
= bfd_getl32 (eihs
.dstsize
);
7363 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u (0x%x)\n"),
7364 dst_vbn
, dst_size
, dst_size
);
7365 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7366 gst_size
= bfd_getl32 (eihs
.gstsize
);
7367 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7369 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7370 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7371 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7374 while (eisd_off
!= 0)
7376 struct vms_eisd eisd
;
7381 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7382 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7384 fprintf (file
, _("cannot read EISD\n"));
7387 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7388 if (len
!= (unsigned)-1)
7392 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7394 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7395 "size: %u, offset: %u)\n"),
7396 (unsigned)bfd_getl32 (eisd
.majorid
),
7397 (unsigned)bfd_getl32 (eisd
.minorid
),
7401 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7402 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7403 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7404 (unsigned)bfd_getl32 (eisd
.secsize
));
7405 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7406 fprintf (file
, _(" flags: 0x%04x"), val
);
7407 if (val
& EISD__M_GBL
)
7408 fprintf (file
, " GBL");
7409 if (val
& EISD__M_CRF
)
7410 fprintf (file
, " CRF");
7411 if (val
& EISD__M_DZRO
)
7412 fprintf (file
, " DZRO");
7413 if (val
& EISD__M_WRT
)
7414 fprintf (file
, " WRT");
7415 if (val
& EISD__M_INITALCODE
)
7416 fprintf (file
, " INITALCODE");
7417 if (val
& EISD__M_BASED
)
7418 fprintf (file
, " BASED");
7419 if (val
& EISD__M_FIXUPVEC
)
7420 fprintf (file
, " FIXUPVEC");
7421 if (val
& EISD__M_RESIDENT
)
7422 fprintf (file
, " RESIDENT");
7423 if (val
& EISD__M_VECTOR
)
7424 fprintf (file
, " VECTOR");
7425 if (val
& EISD__M_PROTECT
)
7426 fprintf (file
, " PROTECT");
7427 if (val
& EISD__M_LASTCLU
)
7428 fprintf (file
, " LASTCLU");
7429 if (val
& EISD__M_EXE
)
7430 fprintf (file
, " EXE");
7431 if (val
& EISD__M_NONSHRADR
)
7432 fprintf (file
, " NONSHRADR");
7433 if (val
& EISD__M_QUAD_LENGTH
)
7434 fprintf (file
, " QUAD_LENGTH");
7435 if (val
& EISD__M_ALLOC_64BIT
)
7436 fprintf (file
, " ALLOC_64BIT");
7437 fprintf (file
, "\n");
7438 if (val
& EISD__M_FIXUPVEC
)
7440 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7441 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7443 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7444 (unsigned)bfd_getl32 (eisd
.vbn
),
7445 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7448 case EISD__K_NORMAL
:
7449 fputs (_("NORMAL"), file
);
7451 case EISD__K_SHRFXD
:
7452 fputs (_("SHRFXD"), file
);
7454 case EISD__K_PRVFXD
:
7455 fputs (_("PRVFXD"), file
);
7457 case EISD__K_SHRPIC
:
7458 fputs (_("SHRPIC"), file
);
7460 case EISD__K_PRVPIC
:
7461 fputs (_("PRVPIC"), file
);
7463 case EISD__K_USRSTACK
:
7464 fputs (_("USRSTACK"), file
);
7467 fputs (_("*unknown*"), file
);
7470 fputs (_(")\n"), file
);
7471 if (val
& EISD__M_GBL
)
7472 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7473 (unsigned)bfd_getl32 (eisd
.ident
),
7474 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7480 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7482 fprintf (file
, _("cannot read DMT\n"));
7486 fprintf (file
, _("Debug module table:\n"));
7488 while (dmt_size
> 0)
7490 struct vms_dmt_header dmth
;
7493 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7495 fprintf (file
, _("cannot read DMT header\n"));
7498 count
= bfd_getl16 (dmth
.psect_count
);
7500 _(" module address: 0x%08x, size: 0x%08x, (%u psects)\n"),
7501 (unsigned)bfd_getl32 (dmth
.modbeg
),
7502 (unsigned)bfd_getl32 (dmth
.size
), count
);
7503 dmt_size
-= sizeof (dmth
);
7506 struct vms_dmt_psect dmtp
;
7508 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7510 fprintf (file
, _("cannot read DMT psect\n"));
7513 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7514 (unsigned)bfd_getl32 (dmtp
.start
),
7515 (unsigned)bfd_getl32 (dmtp
.length
));
7517 dmt_size
-= sizeof (dmtp
);
7524 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7526 fprintf (file
, _("cannot read DST\n"));
7530 evax_bfd_print_dst (abfd
, dst_size
, file
);
7534 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7536 fprintf (file
, _("cannot read GST\n"));
7540 fprintf (file
, _("Global symbol table:\n"));
7541 evax_bfd_print_eobj (abfd
, file
);
7546 struct vms_eiaf
*eiaf
;
7547 unsigned int qrelfixoff
;
7548 unsigned int lrelfixoff
;
7549 unsigned int qdotadroff
;
7550 unsigned int ldotadroff
;
7551 unsigned int shrimgcnt
;
7552 unsigned int shlstoff
;
7553 unsigned int codeadroff
;
7554 unsigned int lpfixoff
;
7555 unsigned int chgprtoff
;
7557 buf
= bfd_malloc (eiaf_size
);
7559 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7560 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7562 fprintf (file
, _("cannot read EIHA\n"));
7566 eiaf
= (struct vms_eiaf
*)buf
;
7568 _("Image activator fixup: (major: %u, minor: %u)\n"),
7569 (unsigned)bfd_getl32 (eiaf
->majorid
),
7570 (unsigned)bfd_getl32 (eiaf
->minorid
));
7571 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7572 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7573 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7574 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7575 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7576 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7577 fprintf (file
, _(" size : %u\n"),
7578 (unsigned)bfd_getl32 (eiaf
->size
));
7579 fprintf (file
, _(" flags: 0x%08x\n"),
7580 (unsigned)bfd_getl32 (eiaf
->flags
));
7581 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7582 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7583 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7584 qrelfixoff
, lrelfixoff
);
7585 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7586 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7587 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7588 qdotadroff
, ldotadroff
);
7589 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7590 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7591 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7592 codeadroff
, lpfixoff
);
7593 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7594 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7595 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7596 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7597 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7598 shlstoff
, shrimgcnt
);
7599 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7600 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7601 (unsigned)bfd_getl32 (eiaf
->permctx
));
7602 fprintf (file
, _(" base_va : 0x%08x\n"),
7603 (unsigned)bfd_getl32 (eiaf
->base_va
));
7604 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7605 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7609 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7612 fprintf (file
, _(" Shareable images:\n"));
7613 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7616 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7617 j
, shl
->size
, shl
->flags
,
7618 shl
->imgnam
[0], shl
->imgnam
+ 1);
7621 if (qrelfixoff
!= 0)
7623 fprintf (file
, _(" quad-word relocation fixups:\n"));
7624 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7626 if (lrelfixoff
!= 0)
7628 fprintf (file
, _(" long-word relocation fixups:\n"));
7629 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
7631 if (qdotadroff
!= 0)
7633 fprintf (file
, _(" quad-word .address reference fixups:\n"));
7634 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
7636 if (ldotadroff
!= 0)
7638 fprintf (file
, _(" long-word .address reference fixups:\n"));
7639 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
7641 if (codeadroff
!= 0)
7643 fprintf (file
, _(" Code Address Reference Fixups:\n"));
7644 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
7648 fprintf (file
, _(" Linkage Pairs Referece Fixups:\n"));
7649 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
7653 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
7654 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
7657 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
7658 for (j
= 0; j
< count
; j
++, eicp
++)
7660 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
7662 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7663 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
7664 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
7665 (unsigned)bfd_getl32 (eicp
->size
),
7666 (unsigned)bfd_getl32 (eicp
->newprt
));
7670 fprintf (file
, "NA");
7672 case PRT__C_RESERVED
:
7673 fprintf (file
, "RES");
7676 fprintf (file
, "KW");
7679 fprintf (file
, "KR");
7682 fprintf (file
, "UW");
7685 fprintf (file
, "EW");
7688 fprintf (file
, "ERKW");
7691 fprintf (file
, "ER");
7694 fprintf (file
, "SW");
7697 fprintf (file
, "SREW");
7700 fprintf (file
, "SRKW");
7703 fprintf (file
, "SR");
7706 fprintf (file
, "URSW");
7709 fprintf (file
, "UREW");
7712 fprintf (file
, "URKW");
7715 fprintf (file
, "UR");
7729 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
7731 FILE *file
= (FILE *)ptr
;
7733 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
7734 evax_bfd_print_image (abfd
, file
);
7737 if (bfd_seek (abfd
, 0, SEEK_SET
))
7739 evax_bfd_print_eobj (abfd
, file
);
7746 /* Slurp ETIR/EDBG/ETBT VMS object records. */
7749 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
7751 asection
*cur_section
;
7752 file_ptr cur_offset
;
7753 asection
*dst_section
;
7754 file_ptr dst_offset
;
7756 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
7762 dst_section
= PRIV (dst_section
);
7766 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
7768 /* Discard the DST section. */
7772 else if (dst_section
)
7774 dst_offset
= dst_section
->output_offset
;
7775 dst_section
= dst_section
->output_section
;
7784 type
= _bfd_vms_get_object_record (abfd
);
7787 vms_debug2 ((2, "next_record failed\n"));
7793 PRIV (image_section
) = cur_section
;
7794 PRIV (image_offset
) = cur_offset
;
7795 res
= _bfd_vms_slurp_etir (abfd
, info
);
7796 cur_section
= PRIV (image_section
);
7797 cur_offset
= PRIV (image_offset
);
7801 if (dst_section
== NULL
)
7803 PRIV (image_section
) = dst_section
;
7804 PRIV (image_offset
) = dst_offset
;
7805 res
= _bfd_vms_slurp_etir (abfd
, info
);
7806 dst_offset
= PRIV (image_offset
);
7815 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
7822 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
7823 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7828 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
7831 alpha_vms_add_fixup_lp (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7833 struct alpha_vms_shlib_el
*sl
;
7834 asection
*sect
= PRIV2 (src
, image_section
);
7835 file_ptr offset
= PRIV2 (src
, image_offset
);
7837 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7838 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7839 sl
->has_fixups
= TRUE
;
7840 VEC_APPEND_EL (sl
->lp
, bfd_vma
,
7841 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7845 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7847 struct alpha_vms_shlib_el
*sl
;
7848 asection
*sect
= PRIV2 (src
, image_section
);
7849 file_ptr offset
= PRIV2 (src
, image_offset
);
7851 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7852 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7853 sl
->has_fixups
= TRUE
;
7854 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
7855 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7859 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
7860 bfd
*shlib
, bfd_vma vec
)
7862 struct alpha_vms_shlib_el
*sl
;
7863 struct alpha_vms_vma_ref
*r
;
7864 asection
*sect
= PRIV2 (src
, image_section
);
7865 file_ptr offset
= PRIV2 (src
, image_offset
);
7867 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7868 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7869 sl
->has_fixups
= TRUE
;
7870 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
7871 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
7876 alpha_vms_add_lw_fixup (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
7877 unsigned int shr ATTRIBUTE_UNUSED
,
7878 bfd_vma vec ATTRIBUTE_UNUSED
)
7885 alpha_vms_add_qw_fixup (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
7886 unsigned int shr ATTRIBUTE_UNUSED
,
7887 bfd_vma vec ATTRIBUTE_UNUSED
)
7894 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7899 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7903 static struct bfd_hash_entry
*
7904 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
7905 struct bfd_hash_table
*table
,
7908 struct alpha_vms_link_hash_entry
*ret
=
7909 (struct alpha_vms_link_hash_entry
*) entry
;
7911 /* Allocate the structure if it has not already been allocated by a
7914 ret
= ((struct alpha_vms_link_hash_entry
*)
7915 bfd_hash_allocate (table
,
7916 sizeof (struct alpha_vms_link_hash_entry
)));
7920 /* Call the allocation method of the superclass. */
7921 ret
= ((struct alpha_vms_link_hash_entry
*)
7922 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
7927 return (struct bfd_hash_entry
*) ret
;
7930 /* Create an Alpha/VMS link hash table. */
7932 static struct bfd_link_hash_table
*
7933 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
7935 struct alpha_vms_link_hash_table
*ret
;
7936 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
7938 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
7941 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
7942 alpha_vms_link_hash_newfunc
,
7943 sizeof (struct alpha_vms_link_hash_entry
)))
7949 VEC_INIT (ret
->shrlibs
);
7956 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
7960 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
7962 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
7963 struct alpha_vms_link_hash_entry
*h
;
7964 struct bfd_link_hash_entry
*h_root
;
7967 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
7970 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
7972 /* In selective_search mode, only add definition that are
7974 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
7975 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
7976 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
7982 h_root
= (struct bfd_link_hash_entry
*) h
;
7983 if (_bfd_generic_link_add_one_symbol
7984 (info
, abfd
, sym
.name
, sym
.flags
, sym
.section
, sym
.value
,
7985 NULL
, FALSE
, FALSE
, &h_root
) == FALSE
)
7987 h
= (struct alpha_vms_link_hash_entry
*) h_root
;
7989 if ((e
->flags
& EGSY__V_DEF
)
7991 && abfd
->xvec
== info
->output_bfd
->xvec
)
7995 if (abfd
->flags
& DYNAMIC
)
7997 struct alpha_vms_shlib_el
*shlib
;
7999 /* We do not want to include any of the sections in a dynamic
8000 object in the output file. See comment in elflink.c. */
8001 bfd_section_list_clear (abfd
);
8003 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8004 struct alpha_vms_shlib_el
);
8006 VEC_INIT (shlib
->ca
);
8007 VEC_INIT (shlib
->lp
);
8008 VEC_INIT (shlib
->qr
);
8009 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8016 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8019 struct bfd_link_hash_entry
**pundef
;
8020 struct bfd_link_hash_entry
**next_pundef
;
8022 /* We only accept VMS libraries. */
8023 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8025 bfd_set_error (bfd_error_wrong_format
);
8029 /* The archive_pass field in the archive itself is used to
8030 initialize PASS, since we may search the same archive multiple
8032 pass
= ++abfd
->archive_pass
;
8034 /* Look through the list of undefined symbols. */
8035 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8037 struct bfd_link_hash_entry
*h
;
8043 next_pundef
= &(*pundef
)->u
.undef
.next
;
8045 /* When a symbol is defined, it is not necessarily removed from
8047 if (h
->type
!= bfd_link_hash_undefined
8048 && h
->type
!= bfd_link_hash_common
)
8050 /* Remove this entry from the list, for general cleanliness
8051 and because we are going to look through the list again
8052 if we search any more libraries. We can't remove the
8053 entry if it is the tail, because that would lose any
8054 entries we add to the list later on. */
8055 if (*pundef
!= info
->hash
->undefs_tail
)
8057 *pundef
= *next_pundef
;
8058 next_pundef
= pundef
;
8063 /* Look for this symbol in the archive hash table. */
8064 symidx
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8065 if (symidx
== BFD_NO_MORE_SYMBOLS
)
8067 /* Nothing in this slot. */
8071 element
= bfd_get_elt_at_index (abfd
, symidx
);
8072 if (element
== NULL
)
8075 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8078 if (! bfd_check_format (element
, bfd_object
))
8080 element
->archive_pass
= -1;
8084 orig_element
= element
;
8085 if (bfd_is_thin_archive (abfd
))
8087 element
= _bfd_vms_lib_get_imagelib_file (element
);
8088 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8090 orig_element
->archive_pass
= -1;
8095 /* Unlike the generic linker, we know that this element provides
8096 a definition for an undefined symbol and we know that we want
8097 to include it. We don't need to check anything. */
8098 if (! (*info
->callbacks
->add_archive_element
) (info
, element
,
8101 if (! alpha_vms_link_add_object_symbols (element
, info
))
8104 orig_element
->archive_pass
= pass
;
8111 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8113 switch (bfd_get_format (abfd
))
8116 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8118 return alpha_vms_link_add_object_symbols (abfd
, info
);
8121 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8123 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8126 bfd_set_error (bfd_error_wrong_format
);
8132 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8134 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8135 unsigned char *content
;
8137 unsigned int sz
= 0;
8138 unsigned int lp_sz
= 0;
8139 unsigned int ca_sz
= 0;
8140 unsigned int qr_sz
= 0;
8141 unsigned int shrimg_cnt
= 0;
8142 struct vms_eiaf
*eiaf
;
8146 /* Shared libraries. */
8147 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8149 struct alpha_vms_shlib_el
*shlib
;
8151 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8153 if (!shlib
->has_fixups
)
8158 if (VEC_COUNT (shlib
->ca
) > 0)
8160 /* Header + entries. */
8162 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8164 if (VEC_COUNT (shlib
->lp
) > 0)
8166 /* Header + entries. */
8168 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8170 if (VEC_COUNT (shlib
->qr
) > 0)
8172 /* Header + entries. */
8174 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8185 /* Finish now if there is no content. */
8186 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8189 /* Allocate section content (round-up size) */
8190 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8191 + ca_sz
+ lp_sz
+ qr_sz
;
8192 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8193 content
= bfd_zalloc (info
->output_bfd
, sz
);
8194 if (content
== NULL
)
8197 sec
= alpha_vms_link_hash (info
)->fixup
;
8198 sec
->contents
= content
;
8201 eiaf
= (struct vms_eiaf
*)content
;
8202 off
= sizeof (struct vms_eiaf
);
8203 bfd_putl32 (0, eiaf
->majorid
);
8204 bfd_putl32 (0, eiaf
->minorid
);
8205 bfd_putl32 (0, eiaf
->iaflink
);
8206 bfd_putl32 (0, eiaf
->fixuplnk
);
8207 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8208 bfd_putl32 (0, eiaf
->flags
);
8209 bfd_putl32 (0, eiaf
->qrelfixoff
);
8210 bfd_putl32 (0, eiaf
->lrelfixoff
);
8211 bfd_putl32 (0, eiaf
->qdotadroff
);
8212 bfd_putl32 (0, eiaf
->ldotadroff
);
8213 bfd_putl32 (0, eiaf
->codeadroff
);
8214 bfd_putl32 (0, eiaf
->lpfixoff
);
8215 bfd_putl32 (0, eiaf
->chgprtoff
);
8216 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8217 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8218 bfd_putl32 (0, eiaf
->shlextra
);
8219 bfd_putl32 (0, eiaf
->permctx
);
8220 bfd_putl32 (0, eiaf
->base_va
);
8221 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8228 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8230 struct alpha_vms_shlib_el
*shlib
;
8231 struct vms_shl
*shl
;
8233 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8235 if (!shlib
->has_fixups
)
8238 /* Renumber shared images. */
8239 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8241 shl
= (struct vms_shl
*)(content
+ off
);
8242 bfd_putl32 (0, shl
->baseva
);
8243 bfd_putl32 (0, shl
->shlptr
);
8244 bfd_putl32 (0, shl
->ident
);
8245 bfd_putl32 (0, shl
->permctx
);
8246 shl
->size
= sizeof (struct vms_shl
);
8247 bfd_putl16 (0, shl
->fill_1
);
8249 bfd_putl32 (0, shl
->icb
);
8250 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8251 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8254 off
+= sizeof (struct vms_shl
);
8260 bfd_putl32 (off
, eiaf
->codeadroff
);
8262 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8264 struct alpha_vms_shlib_el
*shlib
;
8267 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8269 if (VEC_COUNT (shlib
->ca
) == 0)
8272 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8273 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8276 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8278 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8284 bfd_putl32 (0, content
+ off
);
8285 bfd_putl32 (0, content
+ off
+ 4);
8292 bfd_putl32 (off
, eiaf
->lpfixoff
);
8294 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8296 struct alpha_vms_shlib_el
*shlib
;
8299 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8301 if (VEC_COUNT (shlib
->lp
) == 0)
8304 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8305 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8308 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8310 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8316 bfd_putl32 (0, content
+ off
);
8317 bfd_putl32 (0, content
+ off
+ 4);
8324 bfd_putl32 (off
, eiaf
->qdotadroff
);
8326 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8328 struct alpha_vms_shlib_el
*shlib
;
8331 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8333 if (VEC_COUNT (shlib
->qr
) == 0)
8336 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8337 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8340 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8342 struct alpha_vms_vma_ref
*r
;
8343 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8344 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8345 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8350 bfd_putl32 (0, content
+ off
);
8351 bfd_putl32 (0, content
+ off
+ 4);
8362 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8365 struct bfd_link_order
*p
;
8373 bfd_get_outsymbols (abfd
) = NULL
;
8374 bfd_get_symcount (abfd
) = 0;
8376 /* Mark all sections which will be included in the output file. */
8377 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8378 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8379 if (p
->type
== bfd_indirect_link_order
)
8380 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8383 /* Handle all the link order information for the sections. */
8384 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8386 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8387 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8389 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8391 printf (" at 0x%08x - 0x%08x: ",
8392 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8395 case bfd_section_reloc_link_order
:
8396 case bfd_symbol_reloc_link_order
:
8397 printf (" section/symbol reloc\n");
8399 case bfd_indirect_link_order
:
8400 printf (" section %s of %s\n",
8401 p
->u
.indirect
.section
->name
,
8402 p
->u
.indirect
.section
->owner
->filename
);
8404 case bfd_data_link_order
:
8405 printf (" explicit data\n");
8408 printf (" *unknown* type %u\n", p
->type
);
8415 /* Find the entry point. */
8416 if (bfd_get_start_address (abfd
) == 0)
8418 bfd
*startbfd
= NULL
;
8420 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8422 /* Consider only VMS object files. */
8423 if (sub
->xvec
!= abfd
->xvec
)
8426 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8428 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8430 if (startbfd
!= NULL
8431 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8433 (*info
->callbacks
->einfo
)
8434 (_("%P: multiple entry points: in modules %B and %B\n"),
8443 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8444 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8447 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8449 bfd_set_start_address
8450 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8454 /* Allocate contents. */
8455 base_addr
= (bfd_vma
)-1;
8457 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8459 if (o
->flags
& SEC_HAS_CONTENTS
)
8461 o
->contents
= bfd_alloc (abfd
, o
->size
);
8462 if (o
->contents
== NULL
)
8465 if (o
->flags
& SEC_LOAD
)
8467 if (o
->vma
< base_addr
)
8469 if (o
->vma
+ o
->size
> last_addr
)
8470 last_addr
= o
->vma
+ o
->size
;
8474 /* Create the fixup section. */
8475 fixupsec
= bfd_make_section_anyway_with_flags
8476 (info
->output_bfd
, "$FIXUP$",
8477 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8478 if (fixupsec
== NULL
)
8480 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
8481 fixupsec
->vma
= last_addr
;
8483 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
8484 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
8486 /* Create the DMT section, if necessary. */
8487 dst
= PRIV (dst_section
);
8488 if (dst
!= NULL
&& dst
->size
== 0)
8492 dmt
= bfd_make_section_anyway_with_flags
8493 (info
->output_bfd
, "$DMT$",
8494 SEC_DEBUGGING
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8501 /* Read all sections from the inputs. */
8502 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8504 if (sub
->flags
& DYNAMIC
)
8506 alpha_vms_create_eisd_for_shared (abfd
, sub
);
8510 if (!alpha_vms_read_sections_content (sub
, info
))
8514 /* Handle all the link order information for the sections.
8515 Note: past this point, it is not possible to create new sections. */
8516 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8518 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8522 case bfd_section_reloc_link_order
:
8523 case bfd_symbol_reloc_link_order
:
8526 case bfd_indirect_link_order
:
8530 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
8537 /* Compute fixups. */
8538 if (!alpha_vms_build_fixups (info
))
8541 /* Compute the DMT. */
8545 unsigned char *contents
= NULL
;
8547 /* In pass 1, compute the size. In pass 2, write the DMT contents. */
8548 for (pass
= 0; pass
< 2; pass
++)
8550 unsigned int off
= 0;
8552 /* For each object file (ie for each module). */
8553 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8556 struct vms_dmt_header
*dmth
= NULL
;
8557 unsigned int psect_count
;
8559 /* Skip this module if it has no DST. */
8560 sub_dst
= PRIV2 (sub
, dst_section
);
8561 if (sub_dst
== NULL
|| sub_dst
->size
== 0)
8566 /* Write the header. */
8567 dmth
= (struct vms_dmt_header
*)(contents
+ off
);
8568 bfd_putl32 (sub_dst
->output_offset
, dmth
->modbeg
);
8569 bfd_putl32 (sub_dst
->size
, dmth
->size
);
8572 off
+= sizeof (struct vms_dmt_header
);
8575 /* For each section (ie for each psect). */
8576 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
8578 /* Only consider interesting sections. */
8579 if (!(o
->flags
& SEC_ALLOC
))
8581 if (o
->flags
& SEC_LINKER_CREATED
)
8586 /* Write an entry. */
8587 struct vms_dmt_psect
*dmtp
;
8589 dmtp
= (struct vms_dmt_psect
*)(contents
+ off
);
8590 bfd_putl32 (o
->output_offset
+ o
->output_section
->vma
,
8592 bfd_putl32 (o
->size
, dmtp
->length
);
8595 off
+= sizeof (struct vms_dmt_psect
);
8598 bfd_putl32 (psect_count
, dmth
->psect_count
);
8603 contents
= bfd_zalloc (info
->output_bfd
, off
);
8604 if (contents
== NULL
)
8606 dmt
->contents
= contents
;
8611 BFD_ASSERT (off
== dmt
->size
);
8619 /* Read the contents of a section.
8620 buf points to a buffer of buf_size bytes to be filled with
8621 section data (starting at offset into section) */
8624 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
8625 void *buf
, file_ptr offset
,
8626 bfd_size_type count
)
8630 /* Image are easy. */
8631 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8632 return _bfd_generic_get_section_contents (abfd
, section
,
8633 buf
, offset
, count
);
8636 if (offset
+ count
< count
8637 || offset
+ count
> section
->size
)
8639 bfd_set_error (bfd_error_invalid_operation
);
8643 /* Alloc in memory and read ETIRs. */
8644 BFD_ASSERT (section
->contents
== NULL
);
8646 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8648 BFD_ASSERT (sec
->contents
== NULL
);
8650 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
8652 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
8653 if (sec
->contents
== NULL
)
8657 if (!alpha_vms_read_sections_content (abfd
, NULL
))
8659 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8660 if (section
->contents
)
8661 section
->flags
|= SEC_IN_MEMORY
;
8662 memcpy (buf
, section
->contents
+ offset
, count
);
8667 /* Set the format of a file being written. */
8670 alpha_vms_mkobject (bfd
* abfd
)
8672 const bfd_arch_info_type
*arch
;
8674 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
8676 if (!vms_initialize (abfd
))
8679 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
8680 if (PRIV (recwr
.buf
) == NULL
)
8683 arch
= bfd_scan_arch ("alpha");
8687 bfd_set_error (bfd_error_wrong_format
);
8691 abfd
->arch_info
= arch
;
8698 /* Called when the BFD is being closed to do any necessary cleanup. */
8701 vms_close_and_cleanup (bfd
* abfd
)
8703 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
8705 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
8708 if (abfd
->format
== bfd_archive
)
8710 bfd_release (abfd
, abfd
->tdata
.any
);
8711 abfd
->tdata
.any
= NULL
;
8715 if (PRIV (recrd
.buf
) != NULL
)
8716 free (PRIV (recrd
.buf
));
8718 if (PRIV (sections
) != NULL
)
8719 free (PRIV (sections
));
8721 bfd_release (abfd
, abfd
->tdata
.any
);
8722 abfd
->tdata
.any
= NULL
;
8725 if (abfd
->direction
== write_direction
)
8727 /* Last step on VMS is to convert the file to variable record length
8729 if (bfd_cache_close (abfd
) != TRUE
)
8731 if (vms_convert_to_var_unix_filename (abfd
->filename
) != TRUE
)
8739 /* Called when a new section is created. */
8742 vms_new_section_hook (bfd
* abfd
, asection
*section
)
8746 /* Count hasn't been incremented yet. */
8747 unsigned int section_count
= abfd
->section_count
+ 1;
8749 vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
8750 abfd
, section
->index
, section
->name
, section_count
));
8752 bfd_set_section_alignment (abfd
, section
, 0);
8754 if (section_count
> PRIV (section_count
))
8756 amt
= section_count
;
8757 amt
*= sizeof (asection
*);
8758 PRIV (sections
) = bfd_realloc_or_free (PRIV (sections
), amt
);
8759 if (PRIV (sections
) == NULL
)
8761 PRIV (section_count
) = section_count
;
8764 vms_debug2 ((6, "section_count: %d\n", PRIV (section_count
)));
8766 PRIV (sections
)[section
->index
] = section
;
8768 vms_debug2 ((7, "%d: %s\n", section
->index
, section
->name
));
8770 amt
= sizeof (struct vms_section_data_struct
);
8771 section
->used_by_bfd
= (PTR
) bfd_zalloc (abfd
, amt
);
8772 if (section
->used_by_bfd
== NULL
)
8775 if (strcmp (bfd_get_section_name (abfd
, section
), "$DST$") == 0)
8776 PRIV (dst_section
) = section
;
8778 /* Create the section symbol. */
8779 return _bfd_generic_new_section_hook (abfd
, section
);
8782 /* Part 4.5, symbols. */
8784 /* Print symbol to file according to how. how is one of
8785 bfd_print_symbol_name just print the name
8786 bfd_print_symbol_more print more (???)
8787 bfd_print_symbol_all print all we know, which is not much right now :-). */
8790 vms_print_symbol (bfd
* abfd
,
8793 bfd_print_symbol_type how
)
8795 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
8796 abfd
, file
, symbol
, how
));
8800 case bfd_print_symbol_name
:
8801 case bfd_print_symbol_more
:
8802 fprintf ((FILE *)file
," %s", symbol
->name
);
8805 case bfd_print_symbol_all
:
8807 const char *section_name
= symbol
->section
->name
;
8809 bfd_print_symbol_vandf (abfd
, file
, symbol
);
8811 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
8817 /* Return information about symbol in ret.
8819 fill type, value and name
8822 B bss segment symbol
8824 D data segment symbol
8826 t a static function symbol
8827 T text segment symbol
8832 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
8838 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
8840 sec
= symbol
->section
;
8847 else if (bfd_is_com_section (sec
))
8849 else if (bfd_is_abs_section (sec
))
8851 else if (bfd_is_und_section (sec
))
8853 else if (bfd_is_ind_section (sec
))
8855 else if (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
)
8857 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
8859 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
8864 if (ret
->type
!= 'U')
8865 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
8868 ret
->name
= symbol
->name
;
8871 /* Return TRUE if the given symbol sym in the BFD abfd is
8872 a compiler generated local label, else return FALSE. */
8875 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
8878 vms_debug2 ((1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd
, name
));
8879 return name
[0] == '$';
8882 /* Part 4.7, writing an object file. */
8884 /* Sets the contents of the section section in BFD abfd to the data starting
8885 in memory at LOCATION. The data is written to the output section starting
8886 at offset offset for count bytes.
8888 Normally TRUE is returned, else FALSE. Possible error returns are:
8889 o bfd_error_no_contents - The output section does not have the
8890 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
8891 o and some more too */
8894 _bfd_vms_set_section_contents (bfd
* abfd
,
8896 const void * location
,
8898 bfd_size_type count
)
8900 if (section
->contents
== NULL
)
8902 section
->contents
= bfd_alloc (abfd
, section
->size
);
8903 if (section
->contents
== NULL
)
8906 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
8912 /* Set the architecture and machine type in BFD abfd to arch and mach.
8913 Find the correct pointer to a structure and insert it into the arch_info
8917 alpha_vms_set_arch_mach (bfd
*abfd
,
8918 enum bfd_architecture arch
, unsigned long mach
)
8920 if (arch
!= bfd_arch_alpha
8921 && arch
!= bfd_arch_unknown
)
8924 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
8927 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
8930 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
8931 asection
*sec
, flagword no_flags
, flagword flags
)
8933 vms_section_data (sec
)->no_flags
= no_flags
;
8934 vms_section_data (sec
)->flags
= flags
;
8937 struct vms_private_data_struct
*
8938 bfd_vms_get_data (bfd
*abfd
)
8940 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
8943 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
8944 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
8945 #define vms_bfd_copy_link_hash_symbol_type \
8946 _bfd_generic_copy_link_hash_symbol_type
8947 #define vms_bfd_is_group_section bfd_generic_is_group_section
8948 #define vms_bfd_discard_group bfd_generic_discard_group
8949 #define vms_section_already_linked _bfd_generic_section_already_linked
8950 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
8951 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
8953 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
8954 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
8955 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
8956 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
8957 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
8958 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
8960 /* Symbols table. */
8961 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
8962 #define alpha_vms_bfd_is_target_special_symbol \
8963 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
8964 #define alpha_vms_print_symbol vms_print_symbol
8965 #define alpha_vms_get_symbol_info vms_get_symbol_info
8966 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
8967 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
8968 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
8969 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
8970 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
8971 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_dst_line
8972 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
8974 /* Generic table. */
8975 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
8976 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
8977 #define alpha_vms_new_section_hook vms_new_section_hook
8978 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
8979 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
8981 #define alpha_vms_bfd_get_relocated_section_contents \
8982 bfd_generic_get_relocated_section_contents
8984 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
8985 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
8986 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
8987 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
8988 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
8989 #define alpha_vms_section_already_linked \
8990 _bfd_generic_section_already_linked
8992 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
8993 #define alpha_vms_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
8994 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
8995 #define alpha_vms_bfd_copy_link_hash_symbol_type \
8996 _bfd_generic_copy_link_hash_symbol_type
8998 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
9000 #define alpha_vms_get_dynamic_symtab_upper_bound \
9001 _bfd_nodynamic_get_dynamic_symtab_upper_bound
9002 #define alpha_vms_canonicalize_dynamic_symtab \
9003 _bfd_nodynamic_canonicalize_dynamic_symtab
9004 #define alpha_vms_get_dynamic_reloc_upper_bound \
9005 _bfd_nodynamic_get_dynamic_reloc_upper_bound
9006 #define alpha_vms_canonicalize_dynamic_reloc \
9007 _bfd_nodynamic_canonicalize_dynamic_reloc
9009 const bfd_target vms_alpha_vec
=
9011 "vms-alpha", /* Name. */
9012 bfd_target_evax_flavour
,
9013 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
9014 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
9016 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
9017 | WP_TEXT
| D_PAGED
), /* Object flags. */
9018 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
9019 | SEC_READONLY
| SEC_CODE
| SEC_DATA
9020 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
9021 0, /* symbol_leading_char. */
9022 ' ', /* ar_pad_char. */
9023 15, /* ar_max_namelen. */
9024 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9025 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9026 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9027 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
9028 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
9029 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
9031 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
9032 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
9033 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
9034 _bfd_vms_lib_mkarchive
, bfd_false
},
9035 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
9036 _bfd_vms_lib_write_archive_contents
, bfd_false
},
9038 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
9039 BFD_JUMP_TABLE_COPY (vms
),
9040 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
9041 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
9042 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
9043 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
9044 BFD_JUMP_TABLE_WRITE (alpha_vms
),
9045 BFD_JUMP_TABLE_LINK (alpha_vms
),
9046 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),