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
92 /* These are used with DST_S_C_LINE_NUM. */
93 #define DST_S_C_LINE_NUM_HEADER_SIZE 4
95 /* These are used with DST_S_C_SOURCE */
97 #define DST_S_B_PCLINE_UNSBYTE 1
98 #define DST_S_W_PCLINE_UNSWORD 1
99 #define DST_S_L_PCLINE_UNSLONG 1
101 #define DST_S_B_MODBEG_NAME 14
102 #define DST_S_L_RTNBEG_ADDRESS 5
103 #define DST_S_B_RTNBEG_NAME 13
104 #define DST_S_L_RTNEND_SIZE 5
106 /* These are used with DST_S_C_SOURCE. */
107 #define DST_S_C_SOURCE_HEADER_SIZE 4
109 #define DST_S_B_SRC_DF_LENGTH 1
110 #define DST_S_W_SRC_DF_FILEID 3
111 #define DST_S_B_SRC_DF_FILENAME 20
112 #define DST_S_B_SRC_UNSBYTE 1
113 #define DST_S_W_SRC_UNSWORD 1
114 #define DST_S_L_SRC_UNSLONG 1
116 /* Debugger symbol definitions. */
118 #define DBG_S_L_DMT_MODBEG 0
119 #define DBG_S_L_DST_SIZE 4
120 #define DBG_S_W_DMT_PSECT_COUNT 8
121 #define DBG_S_C_DMT_HEADER_SIZE 12
123 #define DBG_S_L_DMT_PSECT_START 0
124 #define DBG_S_L_DMT_PSECT_LENGTH 4
125 #define DBG_S_C_DMT_PSECT_SIZE 8
127 /* VMS module header. */
143 #define EMH_DATE_LENGTH 17
145 /* VMS End-Of-Module records (EOM/EEOM). */
149 unsigned int eom_l_total_lps
;
150 unsigned short eom_w_comcod
;
151 bfd_boolean eom_has_transfer
;
152 unsigned char eom_b_tfrflg
;
153 unsigned int eom_l_psindx
;
154 unsigned int eom_l_tfradr
;
157 struct vms_symbol_entry
163 unsigned char data_type
;
164 unsigned short flags
;
166 /* Section and offset/value of the symbol. */
167 unsigned int section
;
170 /* Section and offset/value for the entry point (only for subprg). */
171 unsigned int code_section
;
172 unsigned int code_value
;
174 /* Symbol vector offset. */
175 unsigned int symbol_vector
;
177 /* Length of the name. */
178 unsigned char namelen
;
183 /* Stack value for push/pop commands. */
191 #define STACKSIZE 128
193 /* A minimal decoding of DST compilation units. We only decode
194 what's needed to get to the line number information. */
204 struct srecinfo
*next
;
212 struct lineinfo
*next
;
219 struct funcinfo
*next
;
227 /* Chain the previously read compilation unit. */
230 /* The module name. */
233 /* The start offset and size of debug info in the DST section. */
237 /* The lowest and highest addresses contained in this compilation
238 unit as specified in the compilation unit header. */
242 /* The listing line table. */
243 struct lineinfo
*line_table
;
245 /* The source record table. */
246 struct srecinfo
*srec_table
;
248 /* A list of the functions found in this module. */
249 struct funcinfo
*func_table
;
251 /* Current allocation of file_table. */
252 unsigned int file_table_count
;
254 /* An array of the files making up this module. */
255 struct fileinfo
*file_table
;
258 /* BFD private data for alpha-vms. */
260 struct vms_private_data_struct
262 /* If true, relocs have been read. */
263 bfd_boolean reloc_done
;
265 /* Record input buffer. */
266 struct vms_rec_rd recrd
;
267 struct vms_rec_wr recwr
;
269 struct hdr_struct hdr_data
; /* data from HDR/EMH record */
270 struct eom_struct eom_data
; /* data from EOM/EEOM record */
271 unsigned int section_count
; /* # of sections in following array */
272 asection
**sections
; /* array of GSD/EGSD sections */
274 /* Array of raw symbols. */
275 struct vms_symbol_entry
**syms
;
277 /* Canonicalized symbols. */
280 /* Number of symbols. */
281 unsigned int gsd_sym_count
;
282 /* Size of the syms array. */
283 unsigned int max_sym_count
;
284 /* Number of procedure symbols. */
285 unsigned int norm_sym_count
;
287 /* Stack used to evaluate TIR/ETIR commands. */
288 struct stack_struct
*stack
;
291 /* Content reading. */
292 asection
*image_section
; /* section for image_ptr */
293 file_ptr image_offset
; /* Offset for image_ptr. */
294 bfd_boolean image_autoextend
; /* Resize section if necessary. */
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
;
760 vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
764 /* Skip odd alignment byte. */
765 if (bfd_tell (abfd
) & 1)
767 if (bfd_bread (PRIV (recrd
.buf
), 1, abfd
) != 1)
769 bfd_set_error (bfd_error_file_truncated
);
772 /* Alignment byte may be present or not. This is not easy to
773 detect but all object record types are not 0 (on Alpha VMS).
774 We also hope that pad byte is 0. */
775 if (PRIV (recrd
.buf
)[0])
779 /* Read the record header */
780 if (bfd_bread (PRIV (recrd
.buf
) + off
, test_len
- off
, abfd
)
783 bfd_set_error (bfd_error_file_truncated
);
787 /* Reset the record pointer. */
788 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
789 maybe_adjust_record_pointer_for_object (abfd
);
791 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
794 type
= bfd_getl16 (PRIV (recrd
.rec
));
796 vms_debug2 ((8, "_bfd_vms_get_obj_record: rec %p, size %d, type %d\n",
797 PRIV (recrd
.rec
), PRIV (recrd
.rec_size
), type
));
802 /* Implement step #2 of the object record reading procedure.
803 Return the size of the record or 0 on failure. */
806 vms_get_remaining_object_record (bfd
*abfd
, int read_so_far
)
808 unsigned int to_read
;
810 vms_debug2 ((8, "vms_get_remaining_obj_record\n"));
812 /* Extract record size. */
813 PRIV (recrd
.rec_size
) = bfd_getl16 (PRIV (recrd
.rec
) + 2);
815 if (PRIV (recrd
.rec_size
) <= 0)
817 bfd_set_error (bfd_error_file_truncated
);
821 /* That's what the linker manual says. */
822 if (PRIV (recrd
.rec_size
) > EOBJ__C_MAXRECSIZ
)
824 bfd_set_error (bfd_error_file_truncated
);
828 /* Take into account object adjustment. */
829 to_read
= PRIV (recrd
.rec_size
);
830 if (PRIV (recrd
.file_format
) == FF_FOREIGN
)
831 to_read
+= VMS_OBJECT_ADJUSTMENT
;
833 /* Adjust the buffer. */
834 if (to_read
> PRIV (recrd
.buf_size
))
837 = (unsigned char *) bfd_realloc (PRIV (recrd
.buf
), to_read
);
838 if (PRIV (recrd
.buf
) == NULL
)
840 PRIV (recrd
.buf_size
) = to_read
;
843 /* Read the remaining record. */
844 to_read
-= read_so_far
;
846 vms_debug2 ((8, "vms_get_remaining_obj_record: to_read %d\n", to_read
));
848 if (bfd_bread (PRIV (recrd
.buf
) + read_so_far
, to_read
, abfd
) != to_read
)
850 bfd_set_error (bfd_error_file_truncated
);
854 /* Reset the record pointer. */
855 PRIV (recrd
.rec
) = PRIV (recrd
.buf
);
856 maybe_adjust_record_pointer_for_object (abfd
);
858 vms_debug2 ((8, "vms_get_remaining_obj_record: size %d\n",
859 PRIV (recrd
.rec_size
)));
861 return PRIV (recrd
.rec_size
);
864 /* Read and process emh record.
865 Return TRUE on success, FALSE on error. */
868 _bfd_vms_slurp_ehdr (bfd
*abfd
)
871 unsigned char *vms_rec
;
874 vms_rec
= PRIV (recrd
.rec
);
876 vms_debug2 ((2, "HDR/EMH\n"));
878 subtype
= bfd_getl16 (vms_rec
+ 4);
880 vms_debug2 ((3, "subtype %d\n", subtype
));
886 PRIV (hdr_data
).hdr_b_strlvl
= vms_rec
[6];
887 PRIV (hdr_data
).hdr_l_arch1
= bfd_getl32 (vms_rec
+ 8);
888 PRIV (hdr_data
).hdr_l_arch2
= bfd_getl32 (vms_rec
+ 12);
889 PRIV (hdr_data
).hdr_l_recsiz
= bfd_getl32 (vms_rec
+ 16);
890 PRIV (hdr_data
).hdr_t_name
= _bfd_vms_save_counted_string (vms_rec
+ 20);
891 ptr
= vms_rec
+ 20 + vms_rec
[20] + 1;
892 PRIV (hdr_data
).hdr_t_version
=_bfd_vms_save_counted_string (ptr
);
894 PRIV (hdr_data
).hdr_t_date
= _bfd_vms_save_sized_string (ptr
, 17);
898 PRIV (hdr_data
).hdr_c_lnm
=
899 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
903 PRIV (hdr_data
).hdr_c_src
=
904 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
908 PRIV (hdr_data
).hdr_c_ttl
=
909 _bfd_vms_save_sized_string (vms_rec
, PRIV (recrd
.rec_size
- 6));
918 bfd_set_error (bfd_error_wrong_format
);
925 /* Typical sections for evax object files. */
927 #define EVAX_ABS_NAME "$ABS$"
928 #define EVAX_CODE_NAME "$CODE$"
929 #define EVAX_LINK_NAME "$LINK$"
930 #define EVAX_DATA_NAME "$DATA$"
931 #define EVAX_BSS_NAME "$BSS$"
932 #define EVAX_READONLYADDR_NAME "$READONLY_ADDR$"
933 #define EVAX_READONLY_NAME "$READONLY$"
934 #define EVAX_LITERAL_NAME "$LITERAL$"
935 #define EVAX_LITERALS_NAME "$LITERALS"
936 #define EVAX_COMMON_NAME "$COMMON$"
937 #define EVAX_LOCAL_NAME "$LOCAL$"
939 struct sec_flags_struct
941 const char *name
; /* Name of section. */
943 flagword flags_always
; /* Flags we set always. */
945 flagword flags_hassize
; /* Flags we set if the section has a size > 0. */
948 /* These flags are deccrtl/vaxcrtl (openVMS 6.2 Alpha) compatible. */
950 static struct sec_flags_struct evax_section_flags
[] =
956 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
958 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
),
960 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_EXE
),
961 (SEC_CODE
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
963 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
),
964 (SEC_DATA
| SEC_READONLY
),
965 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
),
966 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
968 (EGPS__V_REL
| EGPS__V_RD
),
969 (SEC_DATA
| SEC_READONLY
),
970 (EGPS__V_REL
| EGPS__V_RD
),
971 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
973 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
975 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
976 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
978 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
980 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
| EGPS__V_NOMOD
),
982 { EVAX_READONLYADDR_NAME
,
983 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
),
984 (SEC_DATA
| SEC_READONLY
),
985 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_RD
),
986 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
987 { EVAX_READONLY_NAME
,
988 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
| EGPS__V_NOMOD
),
989 (SEC_DATA
| SEC_READONLY
),
990 (EGPS__V_PIC
| EGPS__V_REL
| EGPS__V_SHR
| EGPS__V_RD
),
991 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
993 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
995 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
996 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) },
997 { EVAX_LITERALS_NAME
,
998 (EGPS__V_PIC
| EGPS__V_OVR
),
999 (SEC_DATA
| SEC_READONLY
),
1000 (EGPS__V_PIC
| EGPS__V_OVR
),
1001 (SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_READONLY
| SEC_LOAD
) },
1003 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
1005 (EGPS__V_REL
| EGPS__V_RD
| EGPS__V_WRT
),
1006 (SEC_IN_MEMORY
| SEC_DATA
| SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
) }
1009 /* Retrieve bfd section flags by name and size. */
1012 vms_secflag_by_name (bfd
*abfd ATTRIBUTE_UNUSED
,
1013 struct sec_flags_struct
*section_flags
,
1019 while (section_flags
[i
].name
!= NULL
)
1021 if (strcmp (name
, section_flags
[i
].name
) == 0)
1024 return section_flags
[i
].flags_hassize
;
1026 return section_flags
[i
].flags_always
;
1031 return section_flags
[i
].flags_hassize
;
1032 return section_flags
[i
].flags_always
;
1035 /* Retrieve vms section flags by name and size. */
1038 vms_esecflag_by_name (struct sec_flags_struct
*section_flags
,
1044 while (section_flags
[i
].name
!= NULL
)
1046 if (strcmp (name
, section_flags
[i
].name
) == 0)
1049 return section_flags
[i
].vflags_hassize
;
1051 return section_flags
[i
].vflags_always
;
1056 return section_flags
[i
].vflags_hassize
;
1057 return section_flags
[i
].vflags_always
;
1060 /* Input routines. */
1062 static struct vms_symbol_entry
*
1063 add_symbol (bfd
*abfd
, const unsigned char *ascic
)
1065 struct vms_symbol_entry
*entry
;
1069 entry
= (struct vms_symbol_entry
*)bfd_zalloc (abfd
, sizeof (*entry
) + len
);
1072 entry
->namelen
= len
;
1073 memcpy (entry
->name
, ascic
, len
);
1074 entry
->name
[len
] = 0;
1075 entry
->owner
= abfd
;
1077 if (PRIV (gsd_sym_count
) >= PRIV (max_sym_count
))
1079 if (PRIV (max_sym_count
) == 0)
1081 PRIV (max_sym_count
) = 128;
1082 PRIV (syms
) = bfd_malloc
1083 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*));
1087 PRIV (max_sym_count
) *= 2;
1088 PRIV (syms
) = bfd_realloc
1090 (PRIV (max_sym_count
) * sizeof (struct vms_symbol_entry
*)));
1092 if (PRIV (syms
) == NULL
)
1096 PRIV (syms
)[PRIV (gsd_sym_count
)++] = entry
;
1100 /* Read and process EGSD. Return FALSE on failure. */
1103 _bfd_vms_slurp_egsd (bfd
* abfd
)
1105 int gsd_type
, gsd_size
;
1107 unsigned char *vms_rec
;
1108 flagword new_flags
, old_flags
;
1110 unsigned long base_addr
;
1111 unsigned long align_addr
;
1113 vms_debug2 ((2, "EGSD\n"));
1115 PRIV (recrd
.rec
) += 8; /* Skip type, size, align pad. */
1116 PRIV (recrd
.rec_size
) -= 8;
1118 /* Calculate base address for each section. */
1121 while (PRIV (recrd
.rec_size
) > 0)
1123 vms_rec
= PRIV (recrd
.rec
);
1125 gsd_type
= bfd_getl16 (vms_rec
);
1126 gsd_size
= bfd_getl16 (vms_rec
+ 2);
1128 vms_debug2 ((3, "egsd_type %d\n", gsd_type
));
1134 /* Program section definition. */
1135 struct vms_egps
*egps
= (struct vms_egps
*)vms_rec
;
1136 name
= _bfd_vms_save_counted_string (&egps
->namlng
);
1137 section
= bfd_make_section (abfd
, name
);
1140 old_flags
= bfd_getl16 (egps
->flags
);
1141 vms_section_data (section
)->flags
= old_flags
;
1142 vms_section_data (section
)->no_flags
= 0;
1143 section
->size
= bfd_getl32 (egps
->alloc
);
1144 new_flags
= vms_secflag_by_name (abfd
, evax_section_flags
, name
,
1146 if (!(old_flags
& EGPS__V_NOMOD
))
1148 new_flags
|= SEC_HAS_CONTENTS
;
1149 if (old_flags
& EGPS__V_REL
)
1150 new_flags
|= SEC_RELOC
;
1152 if (!bfd_set_section_flags (abfd
, section
, new_flags
))
1154 section
->alignment_power
= egps
->align
;
1155 align_addr
= (1 << section
->alignment_power
);
1156 if ((base_addr
% align_addr
) != 0)
1157 base_addr
+= (align_addr
- (base_addr
% align_addr
));
1158 section
->vma
= (bfd_vma
)base_addr
;
1159 base_addr
+= section
->size
;
1160 section
->filepos
= (unsigned int)-1;
1162 vms_debug (4, "EGSD P-section %d (%s, flags %04x) ",
1163 section
->index
, name
, old_flags
);
1164 vms_debug (4, "%lu bytes at 0x%08lx (mem %p)\n",
1165 (unsigned long)section
->size
,
1166 (unsigned long)section
->vma
, section
->contents
);
1174 struct vms_symbol_entry
*entry
;
1175 struct vms_egsy
*egsy
= (struct vms_egsy
*) vms_rec
;
1177 old_flags
= bfd_getl16 (egsy
->flags
);
1178 if (old_flags
& EGSY__V_DEF
)
1179 nameoff
= ESDF__B_NAMLNG
;
1181 nameoff
= ESRF__B_NAMLNG
;
1183 entry
= add_symbol (abfd
, vms_rec
+ nameoff
);
1187 /* Allow only duplicate reference. */
1188 if ((entry
->flags
& EGSY__V_DEF
) && (old_flags
& EGSY__V_DEF
))
1191 if (entry
->typ
== 0)
1193 entry
->typ
= gsd_type
;
1194 entry
->data_type
= egsy
->datyp
;
1195 entry
->flags
= old_flags
;
1198 if (old_flags
& EGSY__V_DEF
)
1200 struct vms_esdf
*esdf
= (struct vms_esdf
*)vms_rec
;
1202 entry
->value
= bfd_getl64 (esdf
->value
);
1203 entry
->section
= bfd_getl32 (esdf
->psindx
);
1205 if (old_flags
& EGSY__V_NORM
)
1207 PRIV (norm_sym_count
)++;
1209 entry
->code_value
= bfd_getl64 (esdf
->code_address
);
1210 entry
->code_section
= bfd_getl32 (esdf
->ca_psindx
);
1219 struct vms_symbol_entry
*entry
;
1220 struct vms_egst
*egst
= (struct vms_egst
*)vms_rec
;
1222 old_flags
= bfd_getl16 (egst
->header
.flags
);
1223 if (old_flags
& EGSY__V_DEF
)
1224 nameoff
= ESDF__B_NAMLNG
;
1226 nameoff
= ESRF__B_NAMLNG
;
1228 entry
= add_symbol (abfd
, &egst
->namlng
);
1233 entry
->typ
= gsd_type
;
1234 entry
->data_type
= egst
->header
.datyp
;
1235 entry
->flags
= old_flags
;
1237 entry
->symbol_vector
= bfd_getl32 (egst
->value
);
1239 entry
->section
= bfd_getl32 (egst
->psindx
);
1240 entry
->value
= bfd_getl64 (egst
->lp_2
);
1242 if (old_flags
& EGSY__V_NORM
)
1244 PRIV (norm_sym_count
)++;
1246 entry
->code_value
= bfd_getl64 (egst
->lp_1
);
1247 entry
->code_section
= 0;
1256 (*_bfd_error_handler
) (_("Unknown EGSD subtype %d"), gsd_type
);
1257 bfd_set_error (bfd_error_bad_value
);
1261 PRIV (recrd
.rec_size
) -= gsd_size
;
1262 PRIV (recrd
.rec
) += gsd_size
;
1265 if (PRIV (gsd_sym_count
) > 0)
1266 abfd
->flags
|= HAS_SYMS
;
1271 /* Stack routines for vms ETIR commands. */
1273 /* Push value and section index. */
1276 _bfd_vms_push (bfd
*abfd
, bfd_vma val
, unsigned int reloc
)
1278 vms_debug2 ((4, "<push %08lx (0x%08x) at %d>\n",
1279 (unsigned long)val
, reloc
, PRIV (stackptr
)));
1281 PRIV (stack
[PRIV (stackptr
)]).value
= val
;
1282 PRIV (stack
[PRIV (stackptr
)]).reloc
= reloc
;
1284 if (PRIV (stackptr
) >= STACKSIZE
)
1286 bfd_set_error (bfd_error_bad_value
);
1287 (*_bfd_error_handler
) (_("Stack overflow (%d) in _bfd_vms_push"), PRIV (stackptr
));
1292 /* Pop value and section index. */
1295 _bfd_vms_pop (bfd
*abfd
, bfd_vma
*val
, unsigned int *rel
)
1297 if (PRIV (stackptr
) == 0)
1299 bfd_set_error (bfd_error_bad_value
);
1300 (*_bfd_error_handler
) (_("Stack underflow in _bfd_vms_pop"));
1304 *val
= PRIV (stack
[PRIV (stackptr
)]).value
;
1305 *rel
= PRIV (stack
[PRIV (stackptr
)]).reloc
;
1307 vms_debug2 ((4, "<pop %08lx (0x%08x)>\n", (unsigned long)*val
, *rel
));
1310 /* Routines to fill sections contents during tir/etir read. */
1312 /* Initialize image buffer pointer to be filled. */
1315 image_set_ptr (bfd
*abfd
, bfd_vma vma
, int sect
, struct bfd_link_info
*info
)
1319 vms_debug2 ((4, "image_set_ptr (0x%08x, sect=%d)\n", (unsigned)vma
, sect
));
1321 sec
= PRIV (sections
)[sect
];
1325 /* Reading contents to an output bfd. */
1327 if (sec
->output_section
== NULL
)
1329 /* Section discarded. */
1330 vms_debug2 ((5, " section %s discarded\n", sec
->name
));
1332 /* This is not used. */
1333 PRIV (image_section
) = NULL
;
1334 PRIV (image_offset
) = 0;
1337 PRIV (image_offset
) = sec
->output_offset
+ vma
;
1338 PRIV (image_section
) = sec
->output_section
;
1342 PRIV (image_offset
) = vma
;
1343 PRIV (image_section
) = sec
;
1347 /* Increment image buffer pointer by offset. */
1350 image_inc_ptr (bfd
*abfd
, bfd_vma offset
)
1352 vms_debug2 ((4, "image_inc_ptr (%u)\n", (unsigned)offset
));
1354 PRIV (image_offset
) += offset
;
1357 /* Save current DST location counter under specified index. */
1360 dst_define_location (bfd
*abfd
, unsigned int loc
)
1362 vms_debug2 ((4, "dst_define_location (%d)\n", (int)loc
));
1364 /* Grow the ptr offset table if necessary. */
1365 if (loc
+ 1 > PRIV (dst_ptr_offsets_count
))
1367 PRIV (dst_ptr_offsets
) = bfd_realloc (PRIV (dst_ptr_offsets
),
1368 (loc
+ 1) * sizeof (unsigned int));
1369 PRIV (dst_ptr_offsets_count
) = loc
+ 1;
1372 PRIV (dst_ptr_offsets
)[loc
] = PRIV (image_offset
);
1375 /* Restore saved DST location counter from specified index. */
1378 dst_restore_location (bfd
*abfd
, unsigned int loc
)
1380 vms_debug2 ((4, "dst_restore_location (%d)\n", (int)loc
));
1382 PRIV (image_offset
) = PRIV (dst_ptr_offsets
)[loc
];
1385 /* Retrieve saved DST location counter from specified index. */
1388 dst_retrieve_location (bfd
*abfd
, unsigned int loc
)
1390 vms_debug2 ((4, "dst_retrieve_location (%d)\n", (int)loc
));
1392 return PRIV (dst_ptr_offsets
)[loc
];
1395 /* Check that the DST section is big enough for the specified
1399 dst_check_allocation (bfd
*abfd
, unsigned int size
)
1401 asection
*section
= PRIV (image_section
);
1403 section
->size
+= size
;
1405 /* Grow the section as necessary */
1406 if (section
->size
<= section
->rawsize
)
1410 if (section
->rawsize
== 0)
1411 section
->rawsize
= 1024;
1413 section
->rawsize
*= 2;
1415 while (section
->size
> section
->rawsize
);
1416 section
->contents
= bfd_realloc (section
->contents
, section
->rawsize
);
1419 /* Write multiple bytes to section image. */
1422 image_write (bfd
*abfd
, unsigned char *ptr
, int size
)
1425 _bfd_vms_debug (8, "image_write from (%p, %d) to (%ld)\n", ptr
, size
,
1426 (long)PRIV (image_offset
));
1427 _bfd_hexdump (9, ptr
, size
, 0);
1430 if (PRIV (image_autoextend
))
1431 dst_check_allocation (abfd
, size
);
1433 if (PRIV (image_section
)->contents
!= NULL
)
1435 asection
*sec
= PRIV (image_section
);
1436 file_ptr off
= PRIV (image_offset
);
1439 if (off
> (file_ptr
)sec
->size
1440 || size
> (file_ptr
)sec
->size
1441 || off
+ size
> (file_ptr
)sec
->size
)
1443 bfd_set_error (bfd_error_bad_value
);
1447 memcpy (sec
->contents
+ off
, ptr
, size
);
1450 PRIV (image_offset
) += size
;
1454 /* Write byte to section image. */
1457 image_write_b (bfd
* abfd
, unsigned int value
)
1459 unsigned char data
[1];
1461 vms_debug2 ((6, "image_write_b (%02x)\n", (int) value
));
1465 return image_write (abfd
, data
, sizeof (data
));
1468 /* Write 2-byte word to image. */
1471 image_write_w (bfd
* abfd
, unsigned int value
)
1473 unsigned char data
[2];
1475 vms_debug2 ((6, "image_write_w (%04x)\n", (int) value
));
1477 bfd_putl16 (value
, data
);
1478 return image_write (abfd
, data
, sizeof (data
));
1481 /* Write 4-byte long to image. */
1484 image_write_l (bfd
* abfd
, unsigned long value
)
1486 unsigned char data
[4];
1488 vms_debug2 ((6, "image_write_l (%08lx)\n", value
));
1490 bfd_putl32 (value
, data
);
1491 return image_write (abfd
, data
, sizeof (data
));
1494 /* Write 8-byte quad to image. */
1497 image_write_q (bfd
* abfd
, bfd_vma value
)
1499 unsigned char data
[8];
1501 vms_debug2 ((6, "image_write_q (%08lx)\n", (unsigned long)value
));
1503 bfd_putl64 (value
, data
);
1504 return image_write (abfd
, data
, sizeof (data
));
1508 _bfd_vms_etir_name (int cmd
)
1512 case ETIR__C_STA_GBL
: return "ETIR__C_STA_GBL";
1513 case ETIR__C_STA_LW
: return "ETIR__C_STA_LW";
1514 case ETIR__C_STA_QW
: return "ETIR__C_STA_QW";
1515 case ETIR__C_STA_PQ
: return "ETIR__C_STA_PQ";
1516 case ETIR__C_STA_LI
: return "ETIR__C_STA_LI";
1517 case ETIR__C_STA_MOD
: return "ETIR__C_STA_MOD";
1518 case ETIR__C_STA_CKARG
: return "ETIR__C_STA_CKARG";
1519 case ETIR__C_STO_B
: return "ETIR__C_STO_B";
1520 case ETIR__C_STO_W
: return "ETIR__C_STO_W";
1521 case ETIR__C_STO_GBL
: return "ETIR__C_STO_GBL";
1522 case ETIR__C_STO_CA
: return "ETIR__C_STO_CA";
1523 case ETIR__C_STO_RB
: return "ETIR__C_STO_RB";
1524 case ETIR__C_STO_AB
: return "ETIR__C_STO_AB";
1525 case ETIR__C_STO_OFF
: return "ETIR__C_STO_OFF";
1526 case ETIR__C_STO_IMM
: return "ETIR__C_STO_IMM";
1527 case ETIR__C_STO_IMMR
: return "ETIR__C_STO_IMMR";
1528 case ETIR__C_STO_LW
: return "ETIR__C_STO_LW";
1529 case ETIR__C_STO_QW
: return "ETIR__C_STO_QW";
1530 case ETIR__C_STO_GBL_LW
: return "ETIR__C_STO_GBL_LW";
1531 case ETIR__C_STO_LP_PSB
: return "ETIR__C_STO_LP_PSB";
1532 case ETIR__C_STO_HINT_GBL
: return "ETIR__C_STO_HINT_GBL";
1533 case ETIR__C_STO_HINT_PS
: return "ETIR__C_STO_HINT_PS";
1534 case ETIR__C_OPR_ADD
: return "ETIR__C_OPR_ADD";
1535 case ETIR__C_OPR_SUB
: return "ETIR__C_OPR_SUB";
1536 case ETIR__C_OPR_INSV
: return "ETIR__C_OPR_INSV";
1537 case ETIR__C_OPR_USH
: return "ETIR__C_OPR_USH";
1538 case ETIR__C_OPR_ROT
: return "ETIR__C_OPR_ROT";
1539 case ETIR__C_OPR_REDEF
: return "ETIR__C_OPR_REDEF";
1540 case ETIR__C_OPR_DFLIT
: return "ETIR__C_OPR_DFLIT";
1541 case ETIR__C_STC_LP
: return "ETIR__C_STC_LP";
1542 case ETIR__C_STC_GBL
: return "ETIR__C_STC_GBL";
1543 case ETIR__C_STC_GCA
: return "ETIR__C_STC_GCA";
1544 case ETIR__C_STC_PS
: return "ETIR__C_STC_PS";
1545 case ETIR__C_STC_NBH_PS
: return "ETIR__C_STC_NBH_PS";
1546 case ETIR__C_STC_NOP_GBL
: return "ETIR__C_STC_NOP_GBL";
1547 case ETIR__C_STC_NOP_PS
: return "ETIR__C_STC_NOP_PS";
1548 case ETIR__C_STC_BSR_GBL
: return "ETIR__C_STC_BSR_GBL";
1549 case ETIR__C_STC_BSR_PS
: return "ETIR__C_STC_BSR_PS";
1550 case ETIR__C_STC_LDA_GBL
: return "ETIR__C_STC_LDA_GBL";
1551 case ETIR__C_STC_LDA_PS
: return "ETIR__C_STC_LDA_PS";
1552 case ETIR__C_STC_BOH_GBL
: return "ETIR__C_STC_BOH_GBL";
1553 case ETIR__C_STC_BOH_PS
: return "ETIR__C_STC_BOH_PS";
1554 case ETIR__C_STC_NBH_GBL
: return "ETIR__C_STC_NBH_GBL";
1555 case ETIR__C_STC_LP_PSB
: return "ETIR__C_STC_LP_PSB";
1556 case ETIR__C_CTL_SETRB
: return "ETIR__C_CTL_SETRB";
1557 case ETIR__C_CTL_AUGRB
: return "ETIR__C_CTL_AUGRB";
1558 case ETIR__C_CTL_DFLOC
: return "ETIR__C_CTL_DFLOC";
1559 case ETIR__C_CTL_STLOC
: return "ETIR__C_CTL_STLOC";
1560 case ETIR__C_CTL_STKDL
: return "ETIR__C_CTL_STKDL";
1563 /* These names have not yet been added to this switch statement. */
1564 (*_bfd_error_handler
) (_("unknown ETIR command %d"), cmd
);
1569 #define HIGHBIT(op) ((op & 0x80000000L) == 0x80000000L)
1572 _bfd_vms_get_value (bfd
*abfd
, const unsigned char *ascic
,
1573 struct bfd_link_info
*info
,
1575 struct alpha_vms_link_hash_entry
**hp
)
1580 struct alpha_vms_link_hash_entry
*h
;
1582 /* Not linking. Do not try to resolve the symbol. */
1591 for (i
= 0; i
< len
; i
++)
1592 name
[i
] = ascic
[i
+ 1];
1595 h
= (struct alpha_vms_link_hash_entry
*)
1596 bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
1601 && (h
->root
.type
== bfd_link_hash_defined
1602 || h
->root
.type
== bfd_link_hash_defweak
))
1603 *vma
= h
->root
.u
.def
.value
1604 + h
->root
.u
.def
.section
->output_offset
1605 + h
->root
.u
.def
.section
->output_section
->vma
;
1606 else if (h
&& h
->root
.type
== bfd_link_hash_undefweak
)
1610 if (!(*info
->callbacks
->undefined_symbol
)
1611 (info
, name
, abfd
, PRIV (image_section
), PRIV (image_offset
), TRUE
))
1619 #define RELC_SHR_BASE 0x10000
1620 #define RELC_SEC_BASE 0x20000
1621 #define RELC_MASK 0x0ffff
1624 alpha_vms_sym_to_ctxt (struct alpha_vms_link_hash_entry
*h
)
1626 /* Handle undefined symbols. */
1627 if (h
== NULL
|| h
->sym
== NULL
)
1630 if (h
->sym
->typ
== EGSD__C_SYMG
)
1632 if (h
->sym
->flags
& EGSY__V_REL
)
1633 return RELC_SHR_BASE
+ PRIV2 (h
->sym
->owner
, shr_index
);
1636 /* Can this happen ? I'd like to see an example. */
1640 if (h
->sym
->typ
== EGSD__C_SYM
)
1642 if (h
->sym
->flags
& EGSY__V_REL
)
1651 alpha_vms_get_sym_value (unsigned int sect
, bfd_vma addr
,
1652 struct alpha_vms_link_hash_entry
*h
)
1656 BFD_ASSERT (h
&& (h
->root
.type
== bfd_link_hash_defined
1657 || h
->root
.type
== bfd_link_hash_defweak
));
1659 s
= PRIV2 (h
->root
.u
.def
.section
->owner
, sections
)[sect
];
1660 return s
->output_section
->vma
+ s
->output_offset
+ addr
;
1664 alpha_vms_fix_sec_rel (bfd
*abfd
, struct bfd_link_info
*info
,
1665 unsigned int rel
, bfd_vma vma
)
1667 asection
*sec
= PRIV (sections
)[rel
& RELC_MASK
];
1671 if (sec
->output_section
== NULL
)
1673 return vma
+ sec
->output_section
->vma
+ sec
->output_offset
;
1676 return vma
+ sec
->vma
;
1680 _bfd_vms_slurp_etir (bfd
*abfd
, struct bfd_link_info
*info
)
1683 unsigned int length
;
1684 unsigned char *maxptr
;
1689 struct alpha_vms_link_hash_entry
*h
;
1691 PRIV (recrd
.rec
) += ETIR__C_HEADER_SIZE
;
1692 PRIV (recrd
.rec_size
) -= ETIR__C_HEADER_SIZE
;
1694 ptr
= PRIV (recrd
.rec
);
1695 length
= PRIV (recrd
.rec_size
);
1696 maxptr
= ptr
+ length
;
1698 vms_debug2 ((2, "ETIR: %d bytes\n", length
));
1700 while (ptr
< maxptr
)
1702 int cmd
= bfd_getl16 (ptr
);
1703 int cmd_length
= bfd_getl16 (ptr
+ 2);
1708 _bfd_vms_debug (4, "etir: %s(%d)\n",
1709 _bfd_vms_etir_name (cmd
), cmd
);
1710 _bfd_hexdump (8, ptr
, cmd_length
- 4, (long) ptr
);
1718 stack 32 bit value of symbol (high bits set to 0). */
1719 case ETIR__C_STA_GBL
:
1720 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1721 _bfd_vms_push (abfd
, op1
, alpha_vms_sym_to_ctxt (h
));
1727 stack 32 bit value, sign extend to 64 bit. */
1728 case ETIR__C_STA_LW
:
1729 _bfd_vms_push (abfd
, bfd_getl32 (ptr
), RELC_NONE
);
1735 stack 64 bit value of symbol. */
1736 case ETIR__C_STA_QW
:
1737 _bfd_vms_push (abfd
, bfd_getl64 (ptr
), RELC_NONE
);
1740 /* Stack psect base plus quadword offset
1741 arg: lw section index
1742 qw signed quadword offset (low 32 bits)
1744 Stack qw argument and section index
1745 (see ETIR__C_STO_OFF, ETIR__C_CTL_SETRB). */
1746 case ETIR__C_STA_PQ
:
1750 psect
= bfd_getl32 (ptr
);
1751 if ((unsigned int) psect
>= PRIV (section_count
))
1753 (*_bfd_error_handler
) (_("bad section index in %s"),
1754 _bfd_vms_etir_name (cmd
));
1755 bfd_set_error (bfd_error_bad_value
);
1758 op1
= bfd_getl64 (ptr
+ 4);
1759 _bfd_vms_push (abfd
, op1
, psect
| RELC_SEC_BASE
);
1763 case ETIR__C_STA_LI
:
1764 case ETIR__C_STA_MOD
:
1765 case ETIR__C_STA_CKARG
:
1766 (*_bfd_error_handler
) (_("unsupported STA cmd %s"),
1767 _bfd_vms_etir_name (cmd
));
1771 /* Store byte: pop stack, write byte
1774 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1775 if (rel1
!= RELC_NONE
)
1777 image_write_b (abfd
, (unsigned int) op1
& 0xff);
1780 /* Store word: pop stack, write word
1783 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1784 if (rel1
!= RELC_NONE
)
1786 image_write_w (abfd
, (unsigned int) op1
& 0xffff);
1789 /* Store longword: pop stack, write longword
1791 case ETIR__C_STO_LW
:
1792 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1793 if (rel1
& RELC_SEC_BASE
)
1795 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1798 else if (rel1
& RELC_SHR_BASE
)
1800 alpha_vms_add_lw_fixup (info
, rel1
& RELC_MASK
, op1
);
1803 if (rel1
!= RELC_NONE
)
1805 if (rel1
!= RELC_REL
)
1807 alpha_vms_add_lw_reloc (info
);
1809 image_write_l (abfd
, op1
);
1812 /* Store quadword: pop stack, write quadword
1814 case ETIR__C_STO_QW
:
1815 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1816 if (rel1
& RELC_SEC_BASE
)
1818 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1821 else if (rel1
& RELC_SHR_BASE
)
1823 if (rel1
!= RELC_NONE
)
1825 if (rel1
!= RELC_REL
)
1827 alpha_vms_add_qw_reloc (info
);
1829 image_write_q (abfd
, op1
);
1832 /* Store immediate repeated: pop stack for repeat count
1835 case ETIR__C_STO_IMMR
:
1839 size
= bfd_getl32 (ptr
);
1840 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1841 if (rel1
!= RELC_NONE
)
1844 image_write (abfd
, ptr
+ 4, size
);
1848 /* Store global: write symbol value
1849 arg: cs global symbol name. */
1850 case ETIR__C_STO_GBL
:
1851 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1854 if (h
->sym
->typ
== EGSD__C_SYMG
)
1856 alpha_vms_add_fixup_qr
1857 (info
, abfd
, h
->sym
->owner
, h
->sym
->symbol_vector
);
1862 op1
= alpha_vms_get_sym_value (h
->sym
->section
,
1864 alpha_vms_add_qw_reloc (info
);
1867 image_write_q (abfd
, op1
);
1870 /* Store code address: write address of entry point
1871 arg: cs global symbol name (procedure). */
1872 case ETIR__C_STO_CA
:
1873 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1876 if (h
->sym
->flags
& EGSY__V_NORM
)
1878 /* That's really a procedure. */
1879 if (h
->sym
->typ
== EGSD__C_SYMG
)
1881 alpha_vms_add_fixup_ca (info
, abfd
, h
->sym
->owner
);
1882 op1
= h
->sym
->symbol_vector
;
1886 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1887 h
->sym
->code_value
, h
);
1888 alpha_vms_add_qw_reloc (info
);
1893 /* Symbol is not a procedure. */
1897 image_write_q (abfd
, op1
);
1900 /* Store offset to psect: pop stack, add low 32 bits to base of psect
1902 case ETIR__C_STO_OFF
:
1903 _bfd_vms_pop (abfd
, &op1
, &rel1
);
1905 if (!(rel1
& RELC_SEC_BASE
))
1908 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
1910 image_write_q (abfd
, op1
);
1914 arg: lw count of bytes
1916 case ETIR__C_STO_IMM
:
1920 size
= bfd_getl32 (ptr
);
1921 image_write (abfd
, ptr
+ 4, size
);
1925 /* This code is 'reserved to digital' according to the openVMS
1926 linker manual, however it is generated by the DEC C compiler
1927 and defined in the include file.
1928 FIXME, since the following is just a guess
1929 store global longword: store 32bit value of symbol
1930 arg: cs symbol name. */
1931 case ETIR__C_STO_GBL_LW
:
1932 _bfd_vms_get_value (abfd
, ptr
, info
, &op1
, &h
);
1936 image_write_l (abfd
, op1
);
1939 case ETIR__C_STO_RB
:
1940 case ETIR__C_STO_AB
:
1941 case ETIR__C_STO_LP_PSB
:
1942 (*_bfd_error_handler
) (_("%s: not supported"),
1943 _bfd_vms_etir_name (cmd
));
1946 case ETIR__C_STO_HINT_GBL
:
1947 case ETIR__C_STO_HINT_PS
:
1948 (*_bfd_error_handler
) (_("%s: not implemented"),
1949 _bfd_vms_etir_name (cmd
));
1953 /* 200 Store-conditional Linkage Pair
1955 case ETIR__C_STC_LP
:
1957 /* 202 Store-conditional Address at global address
1961 case ETIR__C_STC_GBL
:
1963 /* 203 Store-conditional Code Address at global address
1965 cs procedure name. */
1966 case ETIR__C_STC_GCA
:
1968 /* 204 Store-conditional Address at psect + offset
1972 case ETIR__C_STC_PS
:
1973 (*_bfd_error_handler
) (_("%s: not supported"),
1974 _bfd_vms_etir_name (cmd
));
1978 /* 201 Store-conditional Linkage Pair with Procedure Signature
1984 case ETIR__C_STC_LP_PSB
:
1985 _bfd_vms_get_value (abfd
, ptr
+ 4, info
, &op1
, &h
);
1988 if (h
->sym
->typ
== EGSD__C_SYMG
)
1990 alpha_vms_add_fixup_lp (info
, abfd
, h
->sym
->owner
);
1991 op1
= h
->sym
->symbol_vector
;
1996 op1
= alpha_vms_get_sym_value (h
->sym
->code_section
,
1997 h
->sym
->code_value
, h
);
1998 op2
= alpha_vms_get_sym_value (h
->sym
->section
,
2004 /* Undefined symbol. */
2008 image_write_q (abfd
, op1
);
2009 image_write_q (abfd
, op2
);
2012 /* 205 Store-conditional NOP at address of global
2014 case ETIR__C_STC_NOP_GBL
:
2017 /* 207 Store-conditional BSR at global address
2020 case ETIR__C_STC_BSR_GBL
:
2023 /* 209 Store-conditional LDA at global address
2026 case ETIR__C_STC_LDA_GBL
:
2029 /* 211 Store-conditional BSR or Hint at global address
2032 case ETIR__C_STC_BOH_GBL
:
2033 /* Currentl ignored. */
2036 /* 213 Store-conditional NOP,BSR or HINT at global address
2039 case ETIR__C_STC_NBH_GBL
:
2041 /* 206 Store-conditional NOP at pect + offset
2044 case ETIR__C_STC_NOP_PS
:
2046 /* 208 Store-conditional BSR at pect + offset
2049 case ETIR__C_STC_BSR_PS
:
2051 /* 210 Store-conditional LDA at psect + offset
2054 case ETIR__C_STC_LDA_PS
:
2056 /* 212 Store-conditional BSR or Hint at pect + offset
2059 case ETIR__C_STC_BOH_PS
:
2061 /* 214 Store-conditional NOP, BSR or HINT at psect + offset
2063 case ETIR__C_STC_NBH_PS
:
2064 (*_bfd_error_handler
) ("%s: not supported",
2065 _bfd_vms_etir_name (cmd
));
2069 /* Det relocation base: pop stack, set image location counter
2071 case ETIR__C_CTL_SETRB
:
2072 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2073 if (!(rel1
& RELC_SEC_BASE
))
2075 image_set_ptr (abfd
, op1
, rel1
& RELC_MASK
, info
);
2078 /* Augment relocation base: increment image location counter by offset
2079 arg: lw offset value. */
2080 case ETIR__C_CTL_AUGRB
:
2081 op1
= bfd_getl32 (ptr
);
2082 image_inc_ptr (abfd
, op1
);
2085 /* Define location: pop index, save location counter under index
2087 case ETIR__C_CTL_DFLOC
:
2088 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2089 if (rel1
!= RELC_NONE
)
2091 dst_define_location (abfd
, op1
);
2094 /* Set location: pop index, restore location counter from index
2096 case ETIR__C_CTL_STLOC
:
2097 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2098 if (rel1
!= RELC_NONE
)
2100 dst_restore_location (abfd
, op1
);
2103 /* Stack defined location: pop index, push location counter from index
2105 case ETIR__C_CTL_STKDL
:
2106 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2107 if (rel1
!= RELC_NONE
)
2109 _bfd_vms_push (abfd
, dst_retrieve_location (abfd
, op1
), RELC_NONE
);
2112 case ETIR__C_OPR_NOP
: /* No-op. */
2115 case ETIR__C_OPR_ADD
: /* Add. */
2116 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2117 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2118 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2120 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2122 _bfd_vms_push (abfd
, op1
+ op2
, rel1
);
2125 case ETIR__C_OPR_SUB
: /* Subtract. */
2126 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2127 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2128 if (rel1
== RELC_NONE
&& rel2
!= RELC_NONE
)
2130 else if ((rel1
& RELC_SEC_BASE
) && (rel2
& RELC_SEC_BASE
))
2132 op1
= alpha_vms_fix_sec_rel (abfd
, info
, rel1
, op1
);
2133 op2
= alpha_vms_fix_sec_rel (abfd
, info
, rel2
, op2
);
2136 else if (rel1
!= RELC_NONE
&& rel2
!= RELC_NONE
)
2138 _bfd_vms_push (abfd
, op2
- op1
, rel1
);
2141 case ETIR__C_OPR_MUL
: /* Multiply. */
2142 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2143 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2144 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2146 _bfd_vms_push (abfd
, op1
* op2
, RELC_NONE
);
2149 case ETIR__C_OPR_DIV
: /* Divide. */
2150 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2151 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2152 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2155 _bfd_vms_push (abfd
, 0, RELC_NONE
);
2157 _bfd_vms_push (abfd
, op2
/ op1
, RELC_NONE
);
2160 case ETIR__C_OPR_AND
: /* Logical AND. */
2161 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2162 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2163 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2165 _bfd_vms_push (abfd
, op1
& op2
, RELC_NONE
);
2168 case ETIR__C_OPR_IOR
: /* Logical inclusive OR. */
2169 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2170 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2171 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2173 _bfd_vms_push (abfd
, op1
| op2
, RELC_NONE
);
2176 case ETIR__C_OPR_EOR
: /* Logical exclusive OR. */
2177 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2178 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2179 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2181 _bfd_vms_push (abfd
, op1
^ op2
, RELC_NONE
);
2184 case ETIR__C_OPR_NEG
: /* Negate. */
2185 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2186 if (rel1
!= RELC_NONE
)
2188 _bfd_vms_push (abfd
, -op1
, RELC_NONE
);
2191 case ETIR__C_OPR_COM
: /* Complement. */
2192 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2193 if (rel1
!= RELC_NONE
)
2195 _bfd_vms_push (abfd
, ~op1
, RELC_NONE
);
2198 case ETIR__C_OPR_ASH
: /* Arithmetic shift. */
2199 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2200 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2201 if (rel1
!= RELC_NONE
|| rel2
!= RELC_NONE
)
2204 (*_bfd_error_handler
) (_("invalid use of %s with contexts"),
2205 _bfd_vms_etir_name (cmd
));
2208 if ((int)op2
< 0) /* Shift right. */
2210 else /* Shift left. */
2212 _bfd_vms_push (abfd
, op1
, RELC_NONE
); /* FIXME: sym. */
2215 case ETIR__C_OPR_INSV
: /* Insert field. */
2216 case ETIR__C_OPR_USH
: /* Unsigned shift. */
2217 case ETIR__C_OPR_ROT
: /* Rotate. */
2218 case ETIR__C_OPR_REDEF
: /* Redefine symbol to current location. */
2219 case ETIR__C_OPR_DFLIT
: /* Define a literal. */
2220 (*_bfd_error_handler
) (_("%s: not supported"),
2221 _bfd_vms_etir_name (cmd
));
2225 case ETIR__C_OPR_SEL
: /* Select. */
2226 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2228 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2231 _bfd_vms_pop (abfd
, &op1
, &rel1
);
2232 _bfd_vms_pop (abfd
, &op2
, &rel2
);
2233 _bfd_vms_push (abfd
, op1
, rel1
);
2238 (*_bfd_error_handler
) (_("reserved cmd %d"), cmd
);
2243 ptr
+= cmd_length
- 4;
2249 /* Process EDBG/ETBT record.
2250 Return TRUE on success, FALSE on error */
2253 vms_slurp_debug (bfd
*abfd
)
2255 asection
*section
= PRIV (dst_section
);
2257 if (section
== NULL
)
2259 /* We have no way to find out beforehand how much debug info there
2260 is in an object file, so pick an initial amount and grow it as
2262 flagword flags
= SEC_HAS_CONTENTS
| SEC_DEBUGGING
| SEC_RELOC
2265 section
= bfd_make_section (abfd
, "$DST$");
2268 if (!bfd_set_section_flags (abfd
, section
, flags
))
2270 PRIV (dst_section
) = section
;
2273 PRIV (image_section
) = section
;
2274 PRIV (image_offset
) = section
->size
;
2275 PRIV (image_autoextend
) = FALSE
;
2277 if (!_bfd_vms_slurp_etir (abfd
, NULL
))
2283 /* Process EDBG record.
2284 Return TRUE on success, FALSE on error. */
2287 _bfd_vms_slurp_edbg (bfd
*abfd
)
2289 vms_debug2 ((2, "EDBG\n"));
2291 abfd
->flags
|= (HAS_DEBUG
| HAS_LINENO
);
2293 return vms_slurp_debug (abfd
);
2296 /* Process ETBT record.
2297 Return TRUE on success, FALSE on error. */
2300 _bfd_vms_slurp_etbt (bfd
*abfd
)
2302 vms_debug2 ((2, "ETBT\n"));
2304 abfd
->flags
|= HAS_LINENO
;
2306 return vms_slurp_debug (abfd
);
2309 /* Process EEOM record.
2310 Return TRUE on success, FALSE on error. */
2313 _bfd_vms_slurp_eeom (bfd
*abfd
)
2315 struct vms_eeom
*eeom
= (struct vms_eeom
*) PRIV (recrd
.rec
);
2317 vms_debug2 ((2, "EEOM\n"));
2319 PRIV (eom_data
).eom_l_total_lps
= bfd_getl32 (eeom
->total_lps
);
2320 PRIV (eom_data
).eom_w_comcod
= bfd_getl16 (eeom
->comcod
);
2321 if (PRIV (eom_data
).eom_w_comcod
> 1)
2323 (*_bfd_error_handler
) (_("Object module NOT error-free !\n"));
2324 bfd_set_error (bfd_error_bad_value
);
2328 PRIV (eom_data
).eom_has_transfer
= FALSE
;
2329 if (PRIV (recrd
.rec_size
) > 10)
2331 PRIV (eom_data
).eom_has_transfer
= TRUE
;
2332 PRIV (eom_data
).eom_b_tfrflg
= eeom
->tfrflg
;
2333 PRIV (eom_data
).eom_l_psindx
= bfd_getl32 (eeom
->psindx
);
2334 PRIV (eom_data
).eom_l_tfradr
= bfd_getl32 (eeom
->tfradr
);
2336 abfd
->start_address
= PRIV (eom_data
).eom_l_tfradr
;
2341 /* Slurp an ordered set of VMS object records. Return FALSE on error. */
2344 _bfd_vms_slurp_object_records (bfd
* abfd
)
2346 int err
, new_type
, type
= -1;
2350 vms_debug2 ((7, "reading at %08lx\n", (unsigned long)bfd_tell (abfd
)));
2352 new_type
= _bfd_vms_get_object_record (abfd
);
2355 vms_debug2 ((2, "next_record failed\n"));
2364 err
= _bfd_vms_slurp_ehdr (abfd
);
2367 err
= _bfd_vms_slurp_eeom (abfd
);
2370 err
= _bfd_vms_slurp_egsd (abfd
);
2373 err
= TRUE
; /* _bfd_vms_slurp_etir (abfd); */
2376 err
= _bfd_vms_slurp_edbg (abfd
);
2379 err
= _bfd_vms_slurp_etbt (abfd
);
2386 vms_debug2 ((2, "slurp type %d failed\n", type
));
2390 while (type
!= EOBJ__C_EEOM
);
2395 /* Initialize private data */
2397 vms_initialize (bfd
* abfd
)
2401 amt
= sizeof (struct vms_private_data_struct
);
2402 abfd
->tdata
.any
= bfd_zalloc (abfd
, amt
);
2403 if (abfd
->tdata
.any
== NULL
)
2406 PRIV (recrd
.file_format
) = FF_UNKNOWN
;
2408 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
2409 PRIV (stack
) = bfd_alloc (abfd
, amt
);
2410 if (PRIV (stack
) == NULL
)
2416 bfd_release (abfd
, abfd
->tdata
.any
);
2417 abfd
->tdata
.any
= NULL
;
2421 /* Check the format for a file being read.
2422 Return a (bfd_target *) if it's an object file or zero if not. */
2424 static const struct bfd_target
*
2425 alpha_vms_object_p (bfd
*abfd
)
2427 PTR tdata_save
= abfd
->tdata
.any
;
2428 unsigned int test_len
;
2431 vms_debug2 ((1, "vms_object_p(%p)\n", abfd
));
2433 /* Allocate alpha-vms specific data. */
2434 if (!vms_initialize (abfd
))
2437 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
2438 goto err_wrong_format
;
2440 /* The first challenge with VMS is to discover the kind of the file.
2442 Image files (executable or shared images) are stored as a raw
2443 stream of bytes (like on UNIX), but there is no magic number.
2445 Object files are written with RMS (record management service), ie
2446 each records are preceeded by its length (on a word - 2 bytes), and
2447 padded for word-alignment. That would be simple but when files
2448 are transfered to a UNIX filesystem (using ftp), records are lost.
2449 Only the raw content of the records are transfered. Fortunately,
2450 the Alpha Object file format also store the length of the record
2451 in the records. Is that clear ? */
2453 /* Minimum is 6 bytes for objects (2 bytes size, 2 bytes record id,
2454 2 bytes size repeated) and 12 bytes for images (4 bytes major id,
2455 4 bytes minor id, 4 bytes length). */
2458 /* Size the main buffer. */
2459 buf
= (unsigned char *) bfd_malloc (test_len
);
2462 PRIV (recrd
.buf
) = buf
;
2463 PRIV (recrd
.buf_size
) = test_len
;
2465 /* Initialize the record pointer. */
2466 PRIV (recrd
.rec
) = buf
;
2468 if (bfd_bread (buf
, test_len
, abfd
) != test_len
)
2470 bfd_set_error (bfd_error_file_truncated
);
2474 /* Is it an image? */
2475 if ((bfd_getl32 (buf
) == EIHD__K_MAJORID
)
2476 && (bfd_getl32 (buf
+ 4) == EIHD__K_MINORID
))
2478 unsigned int to_read
;
2479 unsigned int read_so_far
;
2480 unsigned int remaining
;
2481 unsigned int eisd_offset
, eihs_offset
;
2483 /* Extract the header size. */
2484 PRIV (recrd
.rec_size
) = bfd_getl32 (buf
+ EIHD__L_SIZE
);
2486 if (PRIV (recrd
.rec_size
) > PRIV (recrd
.buf_size
))
2488 buf
= bfd_realloc_or_free (buf
, PRIV (recrd
.rec_size
));
2492 PRIV (recrd
.buf
) = NULL
;
2493 bfd_set_error (bfd_error_no_memory
);
2496 PRIV (recrd
.buf
) = buf
;
2497 PRIV (recrd
.buf_size
) = PRIV (recrd
.rec_size
);
2500 /* Read the remaining record. */
2501 remaining
= PRIV (recrd
.rec_size
) - test_len
;
2502 to_read
= MIN (VMS_BLOCK_SIZE
- test_len
, remaining
);
2503 read_so_far
= test_len
;
2505 while (remaining
> 0)
2507 if (bfd_bread (buf
+ read_so_far
, to_read
, abfd
) != to_read
)
2509 bfd_set_error (bfd_error_file_truncated
);
2510 goto err_wrong_format
;
2513 read_so_far
+= to_read
;
2514 remaining
-= to_read
;
2516 to_read
= MIN (VMS_BLOCK_SIZE
, remaining
);
2519 /* Reset the record pointer. */
2520 PRIV (recrd
.rec
) = buf
;
2522 vms_debug2 ((2, "file type is image\n"));
2524 if (_bfd_vms_slurp_eihd (abfd
, &eisd_offset
, &eihs_offset
) != TRUE
)
2525 goto err_wrong_format
;
2527 if (_bfd_vms_slurp_eisd (abfd
, eisd_offset
) != TRUE
)
2528 goto err_wrong_format
;
2530 /* EIHS is optional. */
2531 if (eihs_offset
!= 0 && _bfd_vms_slurp_eihs (abfd
, eihs_offset
) != TRUE
)
2532 goto err_wrong_format
;
2538 /* Assume it's a module and adjust record pointer if necessary. */
2539 maybe_adjust_record_pointer_for_object (abfd
);
2541 /* But is it really a module? */
2542 if (bfd_getl16 (PRIV (recrd
.rec
)) <= EOBJ__C_MAXRECTYP
2543 && bfd_getl16 (PRIV (recrd
.rec
) + 2) <= EOBJ__C_MAXRECSIZ
)
2545 if (vms_get_remaining_object_record (abfd
, test_len
) <= 0)
2546 goto err_wrong_format
;
2548 vms_debug2 ((2, "file type is module\n"));
2550 type
= bfd_getl16 (PRIV (recrd
.rec
));
2551 if (type
!= EOBJ__C_EMH
|| _bfd_vms_slurp_ehdr (abfd
) != TRUE
)
2552 goto err_wrong_format
;
2554 if (_bfd_vms_slurp_object_records (abfd
) != TRUE
)
2555 goto err_wrong_format
;
2558 goto err_wrong_format
;
2561 /* Set arch_info to alpha. */
2563 if (! bfd_default_set_arch_mach (abfd
, bfd_arch_alpha
, 0))
2564 goto err_wrong_format
;
2569 bfd_set_error (bfd_error_wrong_format
);
2572 if (PRIV (recrd
.buf
))
2573 free (PRIV (recrd
.buf
));
2574 if (abfd
->tdata
.any
!= tdata_save
&& abfd
->tdata
.any
!= NULL
)
2575 bfd_release (abfd
, abfd
->tdata
.any
);
2576 abfd
->tdata
.any
= tdata_save
;
2583 vector_grow1 (struct vector_type
*vec
, size_t elsz
)
2585 if (vec
->nbr_el
+ 1 < vec
->max_el
)
2588 if (vec
->max_el
== 0)
2591 vec
->els
= bfd_malloc2 (vec
->max_el
, elsz
);
2596 vec
->els
= bfd_realloc2 (vec
->els
, vec
->max_el
, elsz
);
2600 /* Bump ABFD file position to next block. */
2603 alpha_vms_file_position_block (bfd
*abfd
)
2606 PRIV (file_pos
) += VMS_BLOCK_SIZE
- 1;
2607 PRIV (file_pos
) -= (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2611 alpha_vms_swap_eisd_out (struct vms_internal_eisd_map
*src
,
2612 struct vms_eisd
*dst
)
2614 bfd_putl32 (src
->u
.eisd
.majorid
, dst
->majorid
);
2615 bfd_putl32 (src
->u
.eisd
.minorid
, dst
->minorid
);
2616 bfd_putl32 (src
->u
.eisd
.eisdsize
, dst
->eisdsize
);
2617 if (src
->u
.eisd
.eisdsize
<= EISD__K_LENEND
)
2619 bfd_putl32 (src
->u
.eisd
.secsize
, dst
->secsize
);
2620 bfd_putl64 (src
->u
.eisd
.virt_addr
, dst
->virt_addr
);
2621 bfd_putl32 (src
->u
.eisd
.flags
, dst
->flags
);
2622 bfd_putl32 (src
->u
.eisd
.vbn
, dst
->vbn
);
2623 dst
->pfc
= src
->u
.eisd
.pfc
;
2624 dst
->matchctl
= src
->u
.eisd
.matchctl
;
2625 dst
->type
= src
->u
.eisd
.type
;
2627 if (src
->u
.eisd
.flags
& EISD__M_GBL
)
2629 bfd_putl32 (src
->u
.gbl_eisd
.ident
, dst
->ident
);
2630 memcpy (dst
->gblnam
, src
->u
.gbl_eisd
.gblnam
,
2631 src
->u
.gbl_eisd
.gblnam
[0] + 1);
2635 /* Append EISD to the list of extra eisd for ABFD. */
2638 alpha_vms_append_extra_eisd (bfd
*abfd
, struct vms_internal_eisd_map
*eisd
)
2641 if (PRIV (gbl_eisd_head
) == NULL
)
2642 PRIV (gbl_eisd_head
) = eisd
;
2644 PRIV (gbl_eisd_tail
)->next
= eisd
;
2645 PRIV (gbl_eisd_tail
) = eisd
;
2649 alpha_vms_create_eisd_for_shared (bfd
*abfd
, bfd
*shrimg
)
2651 struct vms_internal_eisd_map
*eisd
;
2654 namlen
= strlen (PRIV2 (shrimg
, hdr_data
.hdr_t_name
));
2655 if (namlen
+ 5 > EISD__K_GBLNAMLEN
)
2661 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2665 /* Fill the fields. */
2666 eisd
->u
.gbl_eisd
.common
.majorid
= EISD__K_MAJORID
;
2667 eisd
->u
.gbl_eisd
.common
.minorid
= EISD__K_MINORID
;
2668 eisd
->u
.gbl_eisd
.common
.eisdsize
= (EISD__K_LEN
+ 4 + namlen
+ 5 + 3) & ~3;
2669 eisd
->u
.gbl_eisd
.common
.secsize
= VMS_BLOCK_SIZE
; /* Must not be 0. */
2670 eisd
->u
.gbl_eisd
.common
.virt_addr
= 0;
2671 eisd
->u
.gbl_eisd
.common
.flags
= EISD__M_GBL
;
2672 eisd
->u
.gbl_eisd
.common
.vbn
= 0;
2673 eisd
->u
.gbl_eisd
.common
.pfc
= 0;
2674 eisd
->u
.gbl_eisd
.common
.matchctl
= PRIV2 (shrimg
, matchctl
);
2675 eisd
->u
.gbl_eisd
.common
.type
= EISD__K_SHRPIC
;
2677 eisd
->u
.gbl_eisd
.ident
= PRIV2 (shrimg
, ident
);
2678 eisd
->u
.gbl_eisd
.gblnam
[0] = namlen
+ 4;
2679 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1, PRIV2 (shrimg
, hdr_data
.hdr_t_name
),
2681 memcpy (eisd
->u
.gbl_eisd
.gblnam
+ 1 + namlen
, "_001", 4);
2683 /* Append it to the list. */
2684 alpha_vms_append_extra_eisd (abfd
, eisd
);
2690 alpha_vms_create_eisd_for_section (bfd
*abfd
, asection
*sec
)
2692 struct vms_internal_eisd_map
*eisd
;
2694 /* Only for allocating section. */
2695 if (!(sec
->flags
& SEC_ALLOC
))
2698 BFD_ASSERT (vms_section_data (sec
)->eisd
== NULL
);
2699 eisd
= bfd_alloc (abfd
, sizeof (*eisd
));
2702 vms_section_data (sec
)->eisd
= eisd
;
2704 /* Fill the fields. */
2705 eisd
->u
.eisd
.majorid
= EISD__K_MAJORID
;
2706 eisd
->u
.eisd
.minorid
= EISD__K_MINORID
;
2707 eisd
->u
.eisd
.eisdsize
= EISD__K_LEN
;
2708 eisd
->u
.eisd
.secsize
=
2709 (sec
->size
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
2710 eisd
->u
.eisd
.virt_addr
= sec
->vma
;
2711 eisd
->u
.eisd
.flags
= 0;
2712 eisd
->u
.eisd
.vbn
= 0; /* To be later defined. */
2713 eisd
->u
.eisd
.pfc
= 0; /* Default. */
2714 eisd
->u
.eisd
.matchctl
= EISD__K_MATALL
;
2715 eisd
->u
.eisd
.type
= EISD__K_NORMAL
;
2717 if (sec
->flags
& SEC_CODE
)
2718 eisd
->u
.eisd
.flags
|= EISD__M_EXE
;
2719 if (!(sec
->flags
& SEC_READONLY
))
2720 eisd
->u
.eisd
.flags
|= EISD__M_WRT
| EISD__M_CRF
;
2722 if (!(sec
->flags
& SEC_LOAD
))
2724 eisd
->u
.eisd
.flags
|= EISD__M_DZRO
;
2725 eisd
->u
.eisd
.flags
&= ~EISD__M_CRF
;
2727 if (sec
->flags
& SEC_LINKER_CREATED
)
2729 if (strcmp (sec
->name
, "$FIXUP$") == 0)
2730 eisd
->u
.eisd
.flags
|= EISD__M_FIXUPVEC
;
2733 /* Append it to the list. */
2735 if (PRIV (eisd_head
) == NULL
)
2736 PRIV (eisd_head
) = eisd
;
2738 PRIV (eisd_tail
)->next
= eisd
;
2739 PRIV (eisd_tail
) = eisd
;
2745 alpha_vms_write_exec (bfd
*abfd
)
2747 struct vms_eihd eihd
;
2748 struct vms_eiha
*eiha
;
2749 struct vms_eihi
*eihi
;
2750 struct vms_eihs
*eihs
= NULL
;
2752 struct vms_internal_eisd_map
*first_eisd
;
2753 struct vms_internal_eisd_map
*eisd
;
2756 PRIV (file_pos
) = EIHD__C_LENGTH
;
2758 memset (&eihd
, 0, sizeof (eihd
));
2759 memset (eihd
.fill_2
, 0xff, sizeof (eihd
.fill_2
));
2761 bfd_putl32 (EIHD__K_MAJORID
, eihd
.majorid
);
2762 bfd_putl32 (EIHD__K_MINORID
, eihd
.minorid
);
2764 bfd_putl32 (sizeof (eihd
), eihd
.size
);
2765 bfd_putl32 (0, eihd
.isdoff
);
2766 bfd_putl32 (0, eihd
.activoff
);
2767 bfd_putl32 (0, eihd
.symdbgoff
);
2768 bfd_putl32 (0, eihd
.imgidoff
);
2769 bfd_putl32 (0, eihd
.patchoff
);
2770 bfd_putl64 (0, eihd
.iafva
);
2771 bfd_putl32 (0, eihd
.version_array_off
);
2773 bfd_putl32 (EIHD__K_EXE
, eihd
.imgtype
);
2774 bfd_putl32 (0, eihd
.subtype
);
2776 bfd_putl32 (0, eihd
.imgiocnt
);
2777 bfd_putl32 (-1, eihd
.privreqs
);
2778 bfd_putl32 (-1, eihd
.privreqs
+ 4);
2780 bfd_putl32 ((sizeof (eihd
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2782 bfd_putl32 (0, eihd
.lnkflags
);
2783 bfd_putl32 (0, eihd
.ident
);
2784 bfd_putl32 (0, eihd
.sysver
);
2787 bfd_putl32 (0, eihd
.symvect_size
);
2788 bfd_putl32 (16, eihd
.virt_mem_block_size
);
2789 bfd_putl32 (0, eihd
.ext_fixup_off
);
2790 bfd_putl32 (0, eihd
.noopt_psect_off
);
2791 bfd_putl32 (-1, eihd
.alias
);
2794 eiha
= (struct vms_eiha
*)((char *) &eihd
+ PRIV (file_pos
));
2795 bfd_putl32 (PRIV (file_pos
), eihd
.activoff
);
2796 PRIV (file_pos
) += sizeof (struct vms_eiha
);
2798 bfd_putl32 (sizeof (struct vms_eiha
), eiha
->size
);
2799 bfd_putl32 (0, eiha
->spare
);
2800 bfd_putl32 (0x00000340, eiha
->tfradr1
); /* SYS$IMGACT */
2801 bfd_putl32 (0xffffffff, eiha
->tfradr1_h
);
2802 bfd_putl64 (bfd_get_start_address (abfd
), eiha
->tfradr2
);
2803 bfd_putl64 (0, eiha
->tfradr3
);
2804 bfd_putl64 (0, eiha
->tfradr4
);
2805 bfd_putl64 (0, eiha
->inishr
);
2808 eihi
= (struct vms_eihi
*)((char *) &eihd
+ PRIV (file_pos
));
2809 bfd_putl32 (PRIV (file_pos
), eihd
.imgidoff
);
2810 PRIV (file_pos
) += sizeof (struct vms_eihi
);
2812 bfd_putl32 (EIHI__K_MAJORID
, eihi
->majorid
);
2813 bfd_putl32 (EIHI__K_MINORID
, eihi
->minorid
);
2818 module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
2819 len
= strlen (module
);
2820 if (len
> sizeof (eihi
->imgnam
) - 1)
2821 len
= sizeof (eihi
->imgnam
) - 1;
2822 eihi
->imgnam
[0] = len
;
2823 memcpy (eihi
->imgnam
+ 1, module
, len
);
2826 bfd_putl32 (0, eihi
->linktime
+ 0);
2827 bfd_putl32 (0, eihi
->linktime
+ 4);
2829 eihi
->linkid
[0] = 0;
2830 eihi
->imgbid
[0] = 0;
2833 dst
= bfd_get_section_by_name (abfd
, "$DST$");
2834 if (dst
== NULL
|| dst
->size
== 0)
2835 dst
= bfd_get_section_by_name (abfd
, "$TBT$");
2836 if (dst
!= NULL
&& dst
->size
!= 0)
2838 eihs
= (struct vms_eihs
*)((char *) &eihd
+ PRIV (file_pos
));
2839 bfd_putl32 (PRIV (file_pos
), eihd
.symdbgoff
);
2840 PRIV (file_pos
) += sizeof (struct vms_eihs
);
2842 bfd_putl32 (EIHS__K_MAJORID
, eihs
->majorid
);
2843 bfd_putl32 (EIHS__K_MINORID
, eihs
->minorid
);
2844 bfd_putl32 (0, eihs
->dstvbn
);
2845 bfd_putl32 (0, eihs
->dstsize
);
2846 bfd_putl32 (0, eihs
->gstvbn
);
2847 bfd_putl32 (0, eihs
->gstsize
);
2848 bfd_putl32 (0, eihs
->dmtvbn
);
2849 bfd_putl32 (0, eihs
->dmtsize
);
2852 /* One per section. */
2853 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2855 if (!alpha_vms_create_eisd_for_section (abfd
, sec
))
2859 /* Merge section EIDS which extra ones. */
2860 if (PRIV (eisd_tail
))
2861 PRIV (eisd_tail
)->next
= PRIV (gbl_eisd_head
);
2863 PRIV (eisd_head
) = PRIV (gbl_eisd_head
);
2864 if (PRIV (gbl_eisd_tail
))
2865 PRIV (eisd_tail
) = PRIV (gbl_eisd_tail
);
2867 first_eisd
= PRIV (eisd_head
);
2869 /* Add end of eisd. */
2872 eisd
= bfd_zalloc (abfd
, sizeof (*eisd
));
2875 eisd
->u
.eisd
.majorid
= 0;
2876 eisd
->u
.eisd
.minorid
= 0;
2877 eisd
->u
.eisd
.eisdsize
= 0;
2878 alpha_vms_append_extra_eisd (abfd
, eisd
);
2881 /* Place EISD in the file. */
2882 for (eisd
= first_eisd
; eisd
; eisd
= eisd
->next
)
2884 file_ptr room
= VMS_BLOCK_SIZE
- (PRIV (file_pos
) % VMS_BLOCK_SIZE
);
2886 /* First block is a little bit special: there is a word at the end. */
2887 if (PRIV (file_pos
) < VMS_BLOCK_SIZE
&& room
> 2)
2889 if (room
< eisd
->u
.eisd
.eisdsize
+ EISD__K_LENEND
)
2890 alpha_vms_file_position_block (abfd
);
2892 eisd
->file_pos
= PRIV (file_pos
);
2893 PRIV (file_pos
) += eisd
->u
.eisd
.eisdsize
;
2895 if (eisd
->u
.eisd
.flags
& EISD__M_FIXUPVEC
)
2896 bfd_putl64 (eisd
->u
.eisd
.virt_addr
, eihd
.iafva
);
2899 if (first_eisd
!= NULL
)
2901 bfd_putl32 (first_eisd
->file_pos
, eihd
.isdoff
);
2902 /* Real size of end of eisd marker. */
2903 PRIV (file_pos
) += EISD__K_LENEND
;
2906 bfd_putl32 (PRIV (file_pos
), eihd
.size
);
2907 bfd_putl32 ((PRIV (file_pos
) + VMS_BLOCK_SIZE
- 1) / VMS_BLOCK_SIZE
,
2910 /* Place sections. */
2911 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2913 if (!(sec
->flags
& SEC_HAS_CONTENTS
))
2916 eisd
= vms_section_data (sec
)->eisd
;
2918 /* Align on a block. */
2919 alpha_vms_file_position_block (abfd
);
2920 sec
->filepos
= PRIV (file_pos
);
2923 eisd
->u
.eisd
.vbn
= (sec
->filepos
/ VMS_BLOCK_SIZE
) + 1;
2925 PRIV (file_pos
) += sec
->size
;
2928 if (eihs
!= NULL
&& dst
!= NULL
)
2930 bfd_putl32 ((dst
->filepos
/ VMS_BLOCK_SIZE
) + 1, eihs
->dstvbn
);
2931 bfd_putl32 (dst
->size
, eihs
->dstsize
);
2934 /* Write EISD in hdr. */
2935 for (eisd
= first_eisd
; eisd
&& eisd
->file_pos
< VMS_BLOCK_SIZE
;
2937 alpha_vms_swap_eisd_out
2938 (eisd
, (struct vms_eisd
*)((char *)&eihd
+ eisd
->file_pos
));
2940 /* Write first block. */
2941 if (bfd_bwrite (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
2944 /* Write remaining eisd. */
2947 unsigned char blk
[VMS_BLOCK_SIZE
];
2948 struct vms_internal_eisd_map
*next_eisd
;
2950 memset (blk
, 0xff, sizeof (blk
));
2951 while (eisd
!= NULL
)
2953 alpha_vms_swap_eisd_out
2955 (struct vms_eisd
*)(blk
+ (eisd
->file_pos
% VMS_BLOCK_SIZE
)));
2957 next_eisd
= eisd
->next
;
2958 if (next_eisd
== NULL
2959 || (next_eisd
->file_pos
/ VMS_BLOCK_SIZE
2960 != eisd
->file_pos
/ VMS_BLOCK_SIZE
))
2962 if (bfd_bwrite (blk
, sizeof (blk
), abfd
) != sizeof (blk
))
2965 memset (blk
, 0xff, sizeof (blk
));
2971 /* Write sections. */
2972 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
2974 unsigned char blk
[VMS_BLOCK_SIZE
];
2977 if (sec
->size
== 0 || !(sec
->flags
& SEC_HAS_CONTENTS
))
2979 if (bfd_bwrite (sec
->contents
, sec
->size
, abfd
) != sec
->size
)
2983 len
= VMS_BLOCK_SIZE
- sec
->size
% VMS_BLOCK_SIZE
;
2984 if (len
!= VMS_BLOCK_SIZE
)
2986 memset (blk
, 0, len
);
2987 if (bfd_bwrite (blk
, len
, abfd
) != len
)
2997 /* This hash routine borrowed from GNU-EMACS, and strengthened
3001 hash_string (const char *ptr
)
3003 const unsigned char *p
= (unsigned char *) ptr
;
3004 const unsigned char *end
= p
+ strlen (ptr
);
3011 hash
= ((hash
<< 3) + (hash
<< 15) + (hash
>> 28) + c
);
3016 /* Generate a length-hashed VMS symbol name (limited to maxlen chars). */
3019 _bfd_vms_length_hash_symbol (bfd
*abfd
, const char *in
, int maxlen
)
3021 unsigned long result
;
3024 const char *old_name
;
3026 static char outbuf
[EOBJ__C_SYMSIZ
+ 1];
3030 vms_debug (4, "_bfd_vms_length_hash_symbol \"%s\"\n", in
);
3033 if (maxlen
> EOBJ__C_SYMSIZ
)
3034 maxlen
= EOBJ__C_SYMSIZ
;
3036 /* Save this for later. */
3039 /* We may need to truncate the symbol, save the hash for later. */
3040 in_len
= strlen (in
);
3042 result
= (in_len
> maxlen
) ? hash_string (in
) : 0;
3046 /* Do the length checking. */
3047 if (in_len
<= maxlen
)
3051 if (PRIV (flag_hash_long_names
))
3057 strncpy (out
, in
, (size_t) i
);
3061 if ((in_len
> maxlen
)
3062 && PRIV (flag_hash_long_names
))
3063 sprintf (out
, "_%08lx", result
);
3068 vms_debug (4, "--> [%d]\"%s\"\n", (int)strlen (outbuf
), outbuf
);
3072 && PRIV (flag_hash_long_names
)
3073 && PRIV (flag_show_after_trunc
))
3074 printf (_("Symbol %s replaced by %s\n"), old_name
, new_name
);
3079 /* Write section and symbol directory of bfd abfd. Return FALSE on error. */
3082 _bfd_vms_write_egsd (bfd
*abfd
)
3086 unsigned int symnum
;
3087 int last_index
= -1;
3088 char dummy_name
[10];
3090 flagword new_flags
, old_flags
;
3091 int abs_section_index
= 0;
3092 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3094 vms_debug2 ((2, "vms_write_gsd\n"));
3096 /* Output sections. */
3097 section
= abfd
->sections
;
3098 vms_debug2 ((3, "%d sections found\n", abfd
->section_count
));
3100 /* Egsd is quadword aligned. */
3101 _bfd_vms_output_alignment (recwr
, 8);
3103 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3104 _bfd_vms_output_long (recwr
, 0);
3106 while (section
!= 0)
3108 vms_debug2 ((3, "Section #%d %s, %d bytes\n",
3109 section
->index
, section
->name
, (int)section
->size
));
3111 /* Don't write out the VMS debug info section since it is in the
3112 ETBT and EDBG sections in etir. */
3113 if (!strcmp (section
->name
, ".vmsdebug"))
3116 /* 13 bytes egsd, max 31 chars name -> should be 44 bytes. */
3117 if (_bfd_vms_output_check (recwr
, 64) < 0)
3119 _bfd_vms_output_end (abfd
, recwr
);
3120 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3121 _bfd_vms_output_long (recwr
, 0);
3124 /* Create dummy sections to keep consecutive indices. */
3125 while (section
->index
- last_index
> 1)
3127 vms_debug2 ((3, "index %d, last %d\n", section
->index
, last_index
));
3128 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3129 _bfd_vms_output_short (recwr
, 0);
3130 _bfd_vms_output_short (recwr
, 0);
3131 _bfd_vms_output_long (recwr
, 0);
3132 sprintf (dummy_name
, ".DUMMY%02d", last_index
);
3133 _bfd_vms_output_counted (recwr
, dummy_name
);
3134 _bfd_vms_output_end_subrec (recwr
);
3138 /* Don't know if this is necessary for the linker but for now it keeps
3139 vms_slurp_gsd happy */
3140 sname
= (char *)section
->name
;
3144 if ((*sname
== 't') && (strcmp (sname
, "text") == 0))
3145 sname
= EVAX_CODE_NAME
;
3146 else if ((*sname
== 'd') && (strcmp (sname
, "data") == 0))
3147 sname
= EVAX_DATA_NAME
;
3148 else if ((*sname
== 'b') && (strcmp (sname
, "bss") == 0))
3149 sname
= EVAX_BSS_NAME
;
3150 else if ((*sname
== 'l') && (strcmp (sname
, "link") == 0))
3151 sname
= EVAX_LINK_NAME
;
3152 else if ((*sname
== 'r') && (strcmp (sname
, "rdata") == 0))
3153 sname
= EVAX_READONLY_NAME
;
3154 else if ((*sname
== 'l') && (strcmp (sname
, "literal") == 0))
3155 sname
= EVAX_LITERAL_NAME
;
3156 else if ((*sname
== 'l') && (strcmp (sname
, "literals") == 0))
3158 sname
= EVAX_LITERALS_NAME
;
3159 abs_section_index
= section
->index
;
3161 else if ((*sname
== 'c') && (strcmp (sname
, "comm") == 0))
3162 sname
= EVAX_COMMON_NAME
;
3163 else if ((*sname
== 'l') && (strcmp (sname
, "lcomm") == 0))
3164 sname
= EVAX_LOCAL_NAME
;
3167 sname
= _bfd_vms_length_hash_symbol (abfd
, sname
, EOBJ__C_SECSIZ
);
3169 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_PSC
);
3170 _bfd_vms_output_short (recwr
, section
->alignment_power
& 0xff);
3172 if (bfd_is_com_section (section
))
3173 new_flags
= (EGPS__V_OVR
| EGPS__V_REL
| EGPS__V_GBL
| EGPS__V_RD
3174 | EGPS__V_WRT
| EGPS__V_NOMOD
| EGPS__V_COM
);
3176 new_flags
= vms_esecflag_by_name (evax_section_flags
, sname
,
3179 /* Modify them as directed. */
3180 if (section
->flags
& SEC_READONLY
)
3181 new_flags
&= ~EGPS__V_WRT
;
3183 new_flags
&= ~vms_section_data (section
)->no_flags
;
3184 new_flags
|= vms_section_data (section
)->flags
;
3186 vms_debug2 ((3, "sec flags %x\n", section
->flags
));
3187 vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
3188 new_flags
, (unsigned long)section
->size
));
3190 _bfd_vms_output_short (recwr
, new_flags
);
3191 _bfd_vms_output_long (recwr
, (unsigned long) section
->size
);
3192 _bfd_vms_output_counted (recwr
, sname
);
3193 _bfd_vms_output_end_subrec (recwr
);
3195 last_index
= section
->index
;
3197 section
= section
->next
;
3200 /* Output symbols. */
3201 vms_debug2 ((3, "%d symbols found\n", abfd
->symcount
));
3203 bfd_set_start_address (abfd
, (bfd_vma
) -1);
3205 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3209 symbol
= abfd
->outsymbols
[symnum
];
3210 if (*(symbol
->name
) == '_')
3212 if (strcmp (symbol
->name
, "__main") == 0)
3213 bfd_set_start_address (abfd
, (bfd_vma
)symbol
->value
);
3215 old_flags
= symbol
->flags
;
3217 if (old_flags
& BSF_FILE
)
3220 if ((old_flags
& BSF_GLOBAL
) == 0 /* Not xdef... */
3221 && !bfd_is_und_section (symbol
->section
) /* and not xref... */
3222 && !((old_flags
& BSF_SECTION_SYM
) != 0 /* and not LIB$INITIALIZE. */
3223 && strcmp (symbol
->section
->name
, "LIB$INITIALIZE") == 0))
3226 /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. */
3227 if (_bfd_vms_output_check (recwr
, 80) < 0)
3229 _bfd_vms_output_end (abfd
, recwr
);
3230 _bfd_vms_output_begin (recwr
, EOBJ__C_EGSD
);
3231 _bfd_vms_output_long (recwr
, 0);
3234 _bfd_vms_output_begin_subrec (recwr
, EGSD__C_SYM
);
3236 /* Data type, alignment. */
3237 _bfd_vms_output_short (recwr
, 0);
3241 if (old_flags
& BSF_WEAK
)
3242 new_flags
|= EGSY__V_WEAK
;
3243 if (bfd_is_com_section (symbol
->section
)) /* .comm */
3244 new_flags
|= (EGSY__V_WEAK
| EGSY__V_COMM
);
3246 if (old_flags
& BSF_FUNCTION
)
3248 new_flags
|= EGSY__V_NORM
;
3249 new_flags
|= EGSY__V_REL
;
3251 if (old_flags
& BSF_GLOBAL
)
3253 new_flags
|= EGSY__V_DEF
;
3254 if (!bfd_is_abs_section (symbol
->section
))
3255 new_flags
|= EGSY__V_REL
;
3257 _bfd_vms_output_short (recwr
, new_flags
);
3259 if (old_flags
& BSF_GLOBAL
)
3261 /* Symbol definition. */
3262 bfd_vma code_address
= 0;
3263 unsigned long ca_psindx
= 0;
3264 unsigned long psindx
;
3266 if ((old_flags
& BSF_FUNCTION
) && symbol
->udata
.p
!= NULL
)
3270 sym
= ((struct evax_private_udata_struct
*)symbol
->udata
.p
)->enbsym
;
3271 code_address
= sym
->value
;
3272 ca_psindx
= sym
->section
->index
;
3274 if (bfd_is_abs_section (symbol
->section
))
3275 psindx
= abs_section_index
;
3277 psindx
= symbol
->section
->index
;
3279 _bfd_vms_output_quad (recwr
, symbol
->value
);
3280 _bfd_vms_output_quad (recwr
, code_address
);
3281 _bfd_vms_output_long (recwr
, ca_psindx
);
3282 _bfd_vms_output_long (recwr
, psindx
);
3284 hash
= _bfd_vms_length_hash_symbol (abfd
, symbol
->name
, EOBJ__C_SYMSIZ
);
3285 _bfd_vms_output_counted (recwr
, hash
);
3287 _bfd_vms_output_end_subrec (recwr
);
3291 _bfd_vms_output_alignment (recwr
, 8);
3292 _bfd_vms_output_end (abfd
, recwr
);
3297 /* Write object header for bfd abfd. Return FALSE on error. */
3300 _bfd_vms_write_ehdr (bfd
*abfd
)
3303 unsigned int symnum
;
3307 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3309 vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd
));
3311 _bfd_vms_output_alignment (recwr
, 2);
3314 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3315 _bfd_vms_output_short (recwr
, EMH__C_MHD
);
3316 _bfd_vms_output_short (recwr
, EOBJ__C_STRLVL
);
3317 _bfd_vms_output_long (recwr
, 0);
3318 _bfd_vms_output_long (recwr
, 0);
3319 _bfd_vms_output_long (recwr
, MAX_OUTREC_SIZE
);
3321 /* Create module name from filename. */
3322 if (bfd_get_filename (abfd
) != 0)
3324 char *module
= vms_get_module_name (bfd_get_filename (abfd
), TRUE
);
3325 _bfd_vms_output_counted (recwr
, module
);
3329 _bfd_vms_output_counted (recwr
, "NONAME");
3331 _bfd_vms_output_counted (recwr
, BFD_VERSION_STRING
);
3332 _bfd_vms_output_dump (recwr
, get_vms_time_string (), EMH_DATE_LENGTH
);
3333 _bfd_vms_output_fill (recwr
, 0, EMH_DATE_LENGTH
);
3334 _bfd_vms_output_end (abfd
, recwr
);
3337 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3338 _bfd_vms_output_short (recwr
, EMH__C_LNM
);
3339 snprintf (version
, sizeof (version
), "GAS BFD v%s", BFD_VERSION_STRING
);
3340 _bfd_vms_output_dump (recwr
, (unsigned char *)version
, strlen (version
));
3341 _bfd_vms_output_end (abfd
, recwr
);
3344 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3345 _bfd_vms_output_short (recwr
, EMH__C_SRC
);
3347 for (symnum
= 0; symnum
< abfd
->symcount
; symnum
++)
3349 symbol
= abfd
->outsymbols
[symnum
];
3351 if (symbol
->flags
& BSF_FILE
)
3353 if (CONST_STRNEQ ((char *)symbol
->name
, "<CASE:"))
3355 PRIV (flag_hash_long_names
) = symbol
->name
[6] - '0';
3356 PRIV (flag_show_after_trunc
) = symbol
->name
[7] - '0';
3364 _bfd_vms_output_dump (recwr
, (unsigned char *) symbol
->name
,
3365 (int) strlen (symbol
->name
));
3372 if (symnum
== abfd
->symcount
)
3373 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("noname"));
3375 _bfd_vms_output_end (abfd
, recwr
);
3378 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3379 _bfd_vms_output_short (recwr
, EMH__C_TTL
);
3380 _bfd_vms_output_dump (recwr
, (unsigned char *) STRING_COMMA_LEN ("TTL"));
3381 _bfd_vms_output_end (abfd
, recwr
);
3384 _bfd_vms_output_begin (recwr
, EOBJ__C_EMH
);
3385 _bfd_vms_output_short (recwr
, EMH__C_CPR
);
3386 _bfd_vms_output_dump (recwr
,
3387 (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
3389 _bfd_vms_output_end (abfd
, recwr
);
3394 /* Part 4.6, relocations. */
3397 /* WRITE ETIR SECTION
3399 This is still under construction and therefore not documented. */
3401 /* Close the etir/etbt record. */
3404 end_etir_record (bfd
* abfd
)
3406 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3408 _bfd_vms_output_end (abfd
, recwr
);
3412 start_etir_or_etbt_record (bfd
*abfd
, asection
*section
, bfd_vma offset
)
3414 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3416 if (section
->name
[0] == '.' && section
->name
[1] == 'v'
3417 && !strcmp (section
->name
, ".vmsdebug"))
3419 _bfd_vms_output_begin (recwr
, EOBJ__C_ETBT
);
3423 /* Push start offset. */
3424 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3425 _bfd_vms_output_long (recwr
, (unsigned long) 0);
3426 _bfd_vms_output_end_subrec (recwr
);
3429 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_DFLOC
);
3430 _bfd_vms_output_end_subrec (recwr
);
3435 _bfd_vms_output_begin (recwr
, EOBJ__C_ETIR
);
3439 /* Push start offset. */
3440 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3441 _bfd_vms_output_long (recwr
, (unsigned long) section
->index
);
3442 _bfd_vms_output_quad (recwr
, offset
);
3443 _bfd_vms_output_end_subrec (recwr
);
3445 /* Start = pop (). */
3446 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_CTL_SETRB
);
3447 _bfd_vms_output_end_subrec (recwr
);
3452 /* Output a STO_IMM command for SSIZE bytes of data from CPR at virtual
3453 address VADDR in section specified by SEC_INDEX and NAME. */
3456 sto_imm (bfd
*abfd
, asection
*section
,
3457 bfd_size_type ssize
, unsigned char *cptr
, bfd_vma vaddr
)
3460 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3463 _bfd_vms_debug (8, "sto_imm %d bytes\n", (int) ssize
);
3464 _bfd_hexdump (9, cptr
, (int) ssize
, (int) vaddr
);
3469 /* Try all the rest. */
3472 if (_bfd_vms_output_check (recwr
, size
) < 0)
3474 /* Doesn't fit, split ! */
3475 end_etir_record (abfd
);
3477 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3479 size
= _bfd_vms_output_check (recwr
, 0); /* get max size */
3480 if (size
> ssize
) /* more than what's left ? */
3484 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_IMM
);
3485 _bfd_vms_output_long (recwr
, (unsigned long) (size
));
3486 _bfd_vms_output_dump (recwr
, cptr
, size
);
3487 _bfd_vms_output_end_subrec (recwr
);
3490 _bfd_vms_debug (10, "dumped %d bytes\n", (int) size
);
3491 _bfd_hexdump (10, cptr
, (int) size
, (int) vaddr
);
3501 etir_output_check (bfd
*abfd
, asection
*section
, bfd_vma vaddr
, int checklen
)
3503 if (_bfd_vms_output_check (&PRIV (recwr
), checklen
) < 0)
3505 /* Not enough room in this record. Close it and open a new one. */
3506 end_etir_record (abfd
);
3507 start_etir_or_etbt_record (abfd
, section
, vaddr
);
3511 /* Return whether RELOC must be deferred till the end. */
3514 defer_reloc_p (arelent
*reloc
)
3516 switch (reloc
->howto
->type
)
3529 /* Write section contents for bfd abfd. Return FALSE on error. */
3532 _bfd_vms_write_etir (bfd
* abfd
, int objtype ATTRIBUTE_UNUSED
)
3535 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3537 vms_debug2 ((2, "vms_write_tir (%p, %d)\n", abfd
, objtype
));
3539 _bfd_vms_output_alignment (recwr
, 4);
3541 PRIV (vms_linkage_index
) = 1;
3543 for (section
= abfd
->sections
; section
; section
= section
->next
)
3545 vms_debug2 ((4, "writing %d. section '%s' (%d bytes)\n",
3546 section
->index
, section
->name
, (int) (section
->size
)));
3548 if (!(section
->flags
& SEC_HAS_CONTENTS
)
3549 || bfd_is_com_section (section
))
3552 if (!section
->contents
)
3554 bfd_set_error (bfd_error_no_contents
);
3558 start_etir_or_etbt_record (abfd
, section
, 0);
3560 if (section
->flags
& SEC_RELOC
)
3562 bfd_vma curr_addr
= 0;
3563 unsigned char *curr_data
= section
->contents
;
3565 int pass2_needed
= 0;
3566 int pass2_in_progress
= 0;
3569 if (section
->reloc_count
<= 0)
3570 (*_bfd_error_handler
)
3571 (_("SEC_RELOC with no relocs in section %s"), section
->name
);
3576 int i
= section
->reloc_count
;
3577 arelent
**rptr
= section
->orelocation
;
3578 _bfd_vms_debug (4, "%d relocations:\n", i
);
3581 _bfd_vms_debug (4, "sym %s in sec %s, value %08lx, "
3582 "addr %08lx, off %08lx, len %d: %s\n",
3583 (*(*rptr
)->sym_ptr_ptr
)->name
,
3584 (*(*rptr
)->sym_ptr_ptr
)->section
->name
,
3585 (long) (*(*rptr
)->sym_ptr_ptr
)->value
,
3586 (unsigned long)(*rptr
)->address
,
3587 (unsigned long)(*rptr
)->addend
,
3588 bfd_get_reloc_size ((*rptr
)->howto
),
3589 ( *rptr
)->howto
->name
);
3596 for (irel
= 0; irel
< section
->reloc_count
; irel
++)
3598 struct evax_private_udata_struct
*udata
;
3599 arelent
*rptr
= section
->orelocation
[irel
];
3600 bfd_vma addr
= rptr
->address
;
3601 asymbol
*sym
= *rptr
->sym_ptr_ptr
;
3602 asection
*sec
= sym
->section
;
3603 bfd_boolean defer
= defer_reloc_p (rptr
);
3607 if (pass2_in_progress
)
3609 /* Non-deferred relocs have already been output. */
3615 /* Deferred relocs must be output at the very end. */
3622 /* Regular relocs are intertwined with binary data. */
3623 if (curr_addr
> addr
)
3624 (*_bfd_error_handler
) (_("Size error in section %s"),
3626 size
= addr
- curr_addr
;
3627 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3632 size
= bfd_get_reloc_size (rptr
->howto
);
3634 switch (rptr
->howto
->type
)
3636 case ALPHA_R_IGNORE
:
3639 case ALPHA_R_REFLONG
:
3640 if (bfd_is_und_section (sym
->section
))
3642 bfd_vma addend
= rptr
->addend
;
3643 slen
= strlen ((char *) sym
->name
);
3644 hash
= _bfd_vms_length_hash_symbol
3645 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3646 etir_output_check (abfd
, section
, curr_addr
, slen
);
3649 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3650 _bfd_vms_output_counted (recwr
, hash
);
3651 _bfd_vms_output_end_subrec (recwr
);
3652 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3653 _bfd_vms_output_long (recwr
, (unsigned long) addend
);
3654 _bfd_vms_output_end_subrec (recwr
);
3655 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3656 _bfd_vms_output_end_subrec (recwr
);
3657 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3658 _bfd_vms_output_end_subrec (recwr
);
3662 _bfd_vms_output_begin_subrec
3663 (recwr
, ETIR__C_STO_GBL_LW
);
3664 _bfd_vms_output_counted (recwr
, hash
);
3665 _bfd_vms_output_end_subrec (recwr
);
3668 else if (bfd_is_abs_section (sym
->section
))
3670 etir_output_check (abfd
, section
, curr_addr
, 16);
3671 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_LW
);
3672 _bfd_vms_output_long (recwr
, (unsigned long) sym
->value
);
3673 _bfd_vms_output_end_subrec (recwr
);
3674 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3675 _bfd_vms_output_end_subrec (recwr
);
3679 etir_output_check (abfd
, section
, curr_addr
, 32);
3680 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3681 _bfd_vms_output_long (recwr
, (unsigned long) sec
->index
);
3682 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3683 _bfd_vms_output_end_subrec (recwr
);
3684 /* ??? Table B-8 of the OpenVMS Linker Utilily Manual
3685 says that we should have a ETIR__C_STO_OFF here.
3686 But the relocation would not be BFD_RELOC_32 then.
3687 This case is very likely unreachable. */
3688 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_LW
);
3689 _bfd_vms_output_end_subrec (recwr
);
3693 case ALPHA_R_REFQUAD
:
3694 if (bfd_is_und_section (sym
->section
))
3696 bfd_vma addend
= rptr
->addend
;
3697 slen
= strlen ((char *) sym
->name
);
3698 hash
= _bfd_vms_length_hash_symbol
3699 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3700 etir_output_check (abfd
, section
, curr_addr
, slen
);
3703 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_GBL
);
3704 _bfd_vms_output_counted (recwr
, hash
);
3705 _bfd_vms_output_end_subrec (recwr
);
3706 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3707 _bfd_vms_output_quad (recwr
, addend
);
3708 _bfd_vms_output_end_subrec (recwr
);
3709 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_OPR_ADD
);
3710 _bfd_vms_output_end_subrec (recwr
);
3711 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3712 _bfd_vms_output_end_subrec (recwr
);
3716 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_GBL
);
3717 _bfd_vms_output_counted (recwr
, hash
);
3718 _bfd_vms_output_end_subrec (recwr
);
3721 else if (bfd_is_abs_section (sym
->section
))
3723 etir_output_check (abfd
, section
, curr_addr
, 16);
3724 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_QW
);
3725 _bfd_vms_output_quad (recwr
, sym
->value
);
3726 _bfd_vms_output_end_subrec (recwr
);
3727 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_QW
);
3728 _bfd_vms_output_end_subrec (recwr
);
3732 etir_output_check (abfd
, section
, curr_addr
, 32);
3733 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STA_PQ
);
3734 _bfd_vms_output_long (recwr
, (unsigned long) sec
->index
);
3735 _bfd_vms_output_quad (recwr
, rptr
->addend
+ sym
->value
);
3736 _bfd_vms_output_end_subrec (recwr
);
3737 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_OFF
);
3738 _bfd_vms_output_end_subrec (recwr
);
3743 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3746 case ALPHA_R_LINKAGE
:
3747 etir_output_check (abfd
, section
, curr_addr
, 64);
3748 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LP_PSB
);
3749 _bfd_vms_output_long
3750 (recwr
, (unsigned long) PRIV (vms_linkage_index
));
3751 PRIV (vms_linkage_index
) += 2;
3752 hash
= _bfd_vms_length_hash_symbol
3753 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3754 _bfd_vms_output_counted (recwr
, hash
);
3755 _bfd_vms_output_byte (recwr
, 0);
3756 _bfd_vms_output_end_subrec (recwr
);
3759 case ALPHA_R_CODEADDR
:
3760 slen
= strlen ((char *) sym
->name
);
3761 hash
= _bfd_vms_length_hash_symbol
3762 (abfd
, sym
->name
, EOBJ__C_SYMSIZ
);
3763 etir_output_check (abfd
, section
, curr_addr
, slen
);
3764 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STO_CA
);
3765 _bfd_vms_output_counted (recwr
, hash
);
3766 _bfd_vms_output_end_subrec (recwr
);
3771 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3772 etir_output_check (abfd
, section
, curr_addr
,
3773 32 + 1 + strlen (udata
->origname
));
3774 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_NOP_GBL
);
3775 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3776 _bfd_vms_output_long
3777 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3778 _bfd_vms_output_quad (recwr
, rptr
->address
);
3779 _bfd_vms_output_long (recwr
, (unsigned long) 0x47ff041f);
3780 _bfd_vms_output_long
3781 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3782 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3783 _bfd_vms_output_counted
3784 (recwr
, _bfd_vms_length_hash_symbol
3785 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3786 _bfd_vms_output_end_subrec (recwr
);
3790 (*_bfd_error_handler
) (_("Spurious ALPHA_R_BSR reloc"));
3795 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3796 etir_output_check (abfd
, section
, curr_addr
,
3797 32 + 1 + strlen (udata
->origname
));
3798 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_LDA_GBL
);
3799 _bfd_vms_output_long
3800 (recwr
, (unsigned long) udata
->lkindex
+ 1);
3801 _bfd_vms_output_long
3802 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3803 _bfd_vms_output_quad (recwr
, rptr
->address
);
3804 _bfd_vms_output_long (recwr
, (unsigned long) 0x237B0000);
3805 _bfd_vms_output_long
3806 (recwr
, (unsigned long) udata
->bsym
->section
->index
);
3807 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3808 _bfd_vms_output_counted
3809 (recwr
, _bfd_vms_length_hash_symbol
3810 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3811 _bfd_vms_output_end_subrec (recwr
);
3816 = (struct evax_private_udata_struct
*) rptr
->sym_ptr_ptr
;
3817 etir_output_check (abfd
, section
, curr_addr
,
3818 32 + 1 + strlen (udata
->origname
));
3819 _bfd_vms_output_begin_subrec (recwr
, ETIR__C_STC_BOH_GBL
);
3820 _bfd_vms_output_long (recwr
, (unsigned long) udata
->lkindex
);
3821 _bfd_vms_output_long
3822 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3823 _bfd_vms_output_quad (recwr
, rptr
->address
);
3824 _bfd_vms_output_long (recwr
, (unsigned long) 0xD3400000);
3825 _bfd_vms_output_long
3826 (recwr
, (unsigned long) udata
->enbsym
->section
->index
);
3827 _bfd_vms_output_quad (recwr
, rptr
->addend
);
3828 _bfd_vms_output_counted
3829 (recwr
, _bfd_vms_length_hash_symbol
3830 (abfd
, udata
->origname
, EOBJ__C_SYMSIZ
));
3831 _bfd_vms_output_end_subrec (recwr
);
3835 (*_bfd_error_handler
) (_("Unhandled relocation %s"),
3842 } /* End of relocs loop. */
3844 if (!pass2_in_progress
)
3846 /* Output rest of section. */
3847 if (curr_addr
> section
->size
)
3848 (*_bfd_error_handler
) (_("Size error in section %s"),
3850 size
= section
->size
- curr_addr
;
3851 sto_imm (abfd
, section
, size
, curr_data
, curr_addr
);
3857 pass2_in_progress
= 1;
3863 else /* (section->flags & SEC_RELOC) */
3864 sto_imm (abfd
, section
, section
->size
, section
->contents
, 0);
3866 end_etir_record (abfd
);
3869 _bfd_vms_output_alignment (recwr
, 2);
3873 /* Write eom record for bfd abfd. Return FALSE on error. */
3876 _bfd_vms_write_eeom (bfd
*abfd
)
3878 struct vms_rec_wr
*recwr
= &PRIV (recwr
);
3880 vms_debug2 ((2, "vms_write_eeom\n"));
3882 _bfd_vms_output_begin (recwr
, EOBJ__C_EEOM
);
3883 _bfd_vms_output_long (recwr
, (unsigned long) (PRIV (vms_linkage_index
) >> 1));
3884 _bfd_vms_output_byte (recwr
, 0); /* Completion code. */
3885 _bfd_vms_output_byte (recwr
, 0); /* Fill byte. */
3887 if (bfd_get_start_address (abfd
) != (bfd_vma
)-1)
3891 section
= bfd_get_section_by_name (abfd
, ".link");
3894 bfd_set_error (bfd_error_nonrepresentable_section
);
3897 _bfd_vms_output_short (recwr
, 0);
3898 _bfd_vms_output_long (recwr
, (unsigned long) (section
->index
));
3899 _bfd_vms_output_long (recwr
,
3900 (unsigned long) bfd_get_start_address (abfd
));
3901 _bfd_vms_output_long (recwr
, 0);
3904 _bfd_vms_output_end (abfd
, recwr
);
3908 /* Write cached information into a file being written, at bfd_close. */
3911 alpha_vms_write_object_contents (bfd
*abfd
)
3913 vms_debug2 ((1, "vms_write_object_contents (%p)\n", abfd
));
3915 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3917 return alpha_vms_write_exec (abfd
);
3921 if (abfd
->section_count
> 0) /* we have sections */
3923 if (_bfd_vms_write_ehdr (abfd
) != TRUE
)
3925 if (_bfd_vms_write_egsd (abfd
) != TRUE
)
3927 if (_bfd_vms_write_etir (abfd
, EOBJ__C_ETIR
) != TRUE
)
3929 if (_bfd_vms_write_eeom (abfd
) != TRUE
)
3936 /* Debug stuff: nearest line. */
3938 #define SET_MODULE_PARSED(m) \
3939 do { if ((m)->name == NULL) (m)->name = ""; } while (0)
3940 #define IS_MODULE_PARSED(m) ((m)->name != NULL)
3942 /* Build a new module for the specified BFD. */
3944 static struct module
*
3945 new_module (bfd
*abfd
)
3947 struct module
*module
3948 = (struct module
*) bfd_zalloc (abfd
, sizeof (struct module
));
3949 module
->file_table_count
= 16; /* Arbitrary. */
3951 = bfd_malloc (module
->file_table_count
* sizeof (struct fileinfo
));
3955 /* Parse debug info for a module and internalize it. */
3958 parse_module (bfd
*abfd
, struct module
*module
, unsigned char *ptr
,
3961 unsigned char *maxptr
= ptr
+ length
;
3962 unsigned char *src_ptr
, *pcl_ptr
;
3963 unsigned int prev_linum
= 0, curr_linenum
= 0;
3964 bfd_vma prev_pc
= 0, curr_pc
= 0;
3965 struct srecinfo
*curr_srec
, *srec
;
3966 struct lineinfo
*curr_line
, *line
;
3967 struct funcinfo
*funcinfo
;
3969 /* Initialize tables with zero element. */
3970 curr_srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
3971 module
->srec_table
= curr_srec
;
3973 curr_line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
3974 module
->line_table
= curr_line
;
3976 while (length
== -1 || ptr
< maxptr
)
3978 /* The first byte is not counted in the recorded length. */
3979 int rec_length
= bfd_getl16 (ptr
) + 1;
3980 int rec_type
= bfd_getl16 (ptr
+ 2);
3982 vms_debug2 ((2, "DST record: leng %d, type %d\n", rec_length
, rec_type
));
3984 if (length
== -1 && rec_type
== DST__K_MODEND
)
3991 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_MODBEG_NAME
);
3998 vms_debug2 ((3, "module: %s\n", module
->name
));
4005 funcinfo
= (struct funcinfo
*)
4006 bfd_zalloc (abfd
, sizeof (struct funcinfo
));
4008 = _bfd_vms_save_counted_string (ptr
+ DST_S_B_RTNBEG_NAME
);
4009 funcinfo
->low
= bfd_getl32 (ptr
+ DST_S_L_RTNBEG_ADDRESS
);
4010 funcinfo
->next
= module
->func_table
;
4011 module
->func_table
= funcinfo
;
4013 vms_debug2 ((3, "routine: %s at 0x%lx\n",
4014 funcinfo
->name
, (unsigned long) funcinfo
->low
));
4018 module
->func_table
->high
= module
->func_table
->low
4019 + bfd_getl32 (ptr
+ DST_S_L_RTNEND_SIZE
) - 1;
4021 if (module
->func_table
->high
> module
->high
)
4022 module
->high
= module
->func_table
->high
;
4024 vms_debug2 ((3, "end routine\n"));
4028 vms_debug2 ((3, "prologue\n"));
4032 vms_debug2 ((3, "epilog\n"));
4036 vms_debug2 ((3, "block\n"));
4040 vms_debug2 ((3, "end block\n"));
4044 src_ptr
= ptr
+ DST_S_C_SOURCE_HEADER_SIZE
;
4046 vms_debug2 ((3, "source info\n"));
4048 while (src_ptr
< ptr
+ rec_length
)
4050 int cmd
= src_ptr
[0], cmd_length
, data
;
4054 case DST__K_SRC_DECLFILE
:
4057 = bfd_getl16 (src_ptr
+ DST_S_W_SRC_DF_FILEID
);
4059 = _bfd_vms_save_counted_string (src_ptr
4060 + DST_S_B_SRC_DF_FILENAME
);
4062 while (fileid
>= module
->file_table_count
)
4064 module
->file_table_count
*= 2;
4066 = bfd_realloc (module
->file_table
,
4067 module
->file_table_count
4068 * sizeof (struct fileinfo
));
4071 module
->file_table
[fileid
].name
= filename
;
4072 module
->file_table
[fileid
].srec
= 1;
4073 cmd_length
= src_ptr
[DST_S_B_SRC_DF_LENGTH
] + 2;
4074 vms_debug2 ((4, "DST_S_C_SRC_DECLFILE: %d, %s\n",
4075 fileid
, module
->file_table
[fileid
].name
));
4079 case DST__K_SRC_DEFLINES_B
:
4080 /* Perform the association and set the next higher index
4082 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4083 srec
= (struct srecinfo
*)
4084 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4085 srec
->line
= curr_srec
->line
+ data
;
4086 srec
->srec
= curr_srec
->srec
+ data
;
4087 srec
->sfile
= curr_srec
->sfile
;
4088 curr_srec
->next
= srec
;
4091 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_B: %d\n", data
));
4094 case DST__K_SRC_DEFLINES_W
:
4095 /* Perform the association and set the next higher index
4097 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4098 srec
= (struct srecinfo
*)
4099 bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4100 srec
->line
= curr_srec
->line
+ data
;
4101 srec
->srec
= curr_srec
->srec
+ data
,
4102 srec
->sfile
= curr_srec
->sfile
;
4103 curr_srec
->next
= srec
;
4106 vms_debug2 ((4, "DST_S_C_SRC_DEFLINES_W: %d\n", data
));
4109 case DST__K_SRC_INCRLNUM_B
:
4110 data
= src_ptr
[DST_S_B_SRC_UNSBYTE
];
4111 curr_srec
->line
+= data
;
4113 vms_debug2 ((4, "DST_S_C_SRC_INCRLNUM_B: %d\n", data
));
4116 case DST__K_SRC_SETFILE
:
4117 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4118 curr_srec
->sfile
= data
;
4119 curr_srec
->srec
= module
->file_table
[data
].srec
;
4121 vms_debug2 ((4, "DST_S_C_SRC_SETFILE: %d\n", data
));
4124 case DST__K_SRC_SETLNUM_L
:
4125 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4126 curr_srec
->line
= data
;
4128 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_L: %d\n", data
));
4131 case DST__K_SRC_SETLNUM_W
:
4132 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4133 curr_srec
->line
= data
;
4135 vms_debug2 ((4, "DST_S_C_SRC_SETLNUM_W: %d\n", data
));
4138 case DST__K_SRC_SETREC_L
:
4139 data
= bfd_getl32 (src_ptr
+ DST_S_L_SRC_UNSLONG
);
4140 curr_srec
->srec
= data
;
4141 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4143 vms_debug2 ((4, "DST_S_C_SRC_SETREC_L: %d\n", data
));
4146 case DST__K_SRC_SETREC_W
:
4147 data
= bfd_getl16 (src_ptr
+ DST_S_W_SRC_UNSWORD
);
4148 curr_srec
->srec
= data
;
4149 module
->file_table
[curr_srec
->sfile
].srec
= data
;
4151 vms_debug2 ((4, "DST_S_C_SRC_SETREC_W: %d\n", data
));
4154 case DST__K_SRC_FORMFEED
:
4156 vms_debug2 ((4, "DST_S_C_SRC_FORMFEED\n"));
4160 (*_bfd_error_handler
) (_("unknown source command %d"),
4166 src_ptr
+= cmd_length
;
4170 case DST__K_LINE_NUM
:
4171 pcl_ptr
= ptr
+ DST_S_C_LINE_NUM_HEADER_SIZE
;
4173 vms_debug2 ((3, "line info\n"));
4175 while (pcl_ptr
< ptr
+ rec_length
)
4177 /* The command byte is signed so we must sign-extend it. */
4178 int cmd
= ((signed char *)pcl_ptr
)[0], cmd_length
, data
;
4182 case DST__K_DELTA_PC_W
:
4183 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4187 vms_debug2 ((4, "DST__K_DELTA_PC_W: %d\n", data
));
4190 case DST__K_DELTA_PC_L
:
4191 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4195 vms_debug2 ((4, "DST__K_DELTA_PC_L: %d\n", data
));
4198 case DST__K_INCR_LINUM
:
4199 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4200 curr_linenum
+= data
;
4202 vms_debug2 ((4, "DST__K_INCR_LINUM: %d\n", data
));
4205 case DST__K_INCR_LINUM_W
:
4206 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4207 curr_linenum
+= data
;
4209 vms_debug2 ((4, "DST__K_INCR_LINUM_W: %d\n", data
));
4212 case DST__K_INCR_LINUM_L
:
4213 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4214 curr_linenum
+= data
;
4216 vms_debug2 ((4, "DST__K_INCR_LINUM_L: %d\n", data
));
4219 case DST__K_SET_LINUM_INCR
:
4220 (*_bfd_error_handler
)
4221 (_("DST__K_SET_LINUM_INCR not implemented"));
4225 case DST__K_SET_LINUM_INCR_W
:
4226 (*_bfd_error_handler
)
4227 (_("DST__K_SET_LINUM_INCR_W not implemented"));
4231 case DST__K_RESET_LINUM_INCR
:
4232 (*_bfd_error_handler
)
4233 (_("DST__K_RESET_LINUM_INCR not implemented"));
4237 case DST__K_BEG_STMT_MODE
:
4238 (*_bfd_error_handler
)
4239 (_("DST__K_BEG_STMT_MODE not implemented"));
4243 case DST__K_END_STMT_MODE
:
4244 (*_bfd_error_handler
)
4245 (_("DST__K_END_STMT_MODE not implemented"));
4249 case DST__K_SET_LINUM_B
:
4250 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4251 curr_linenum
= data
;
4253 vms_debug2 ((4, "DST__K_SET_LINUM_B: %d\n", data
));
4256 case DST__K_SET_LINUM
:
4257 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4258 curr_linenum
= data
;
4260 vms_debug2 ((4, "DST__K_SET_LINE_NUM: %d\n", data
));
4263 case DST__K_SET_LINUM_L
:
4264 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4265 curr_linenum
= data
;
4267 vms_debug2 ((4, "DST__K_SET_LINUM_L: %d\n", data
));
4271 (*_bfd_error_handler
)
4272 (_("DST__K_SET_PC not implemented"));
4276 case DST__K_SET_PC_W
:
4277 (*_bfd_error_handler
)
4278 (_("DST__K_SET_PC_W not implemented"));
4282 case DST__K_SET_PC_L
:
4283 (*_bfd_error_handler
)
4284 (_("DST__K_SET_PC_L not implemented"));
4288 case DST__K_SET_STMTNUM
:
4289 (*_bfd_error_handler
)
4290 (_("DST__K_SET_STMTNUM not implemented"));
4295 data
= pcl_ptr
[DST_S_B_PCLINE_UNSBYTE
];
4298 vms_debug2 ((4, "DST__K_TERM: %d\n", data
));
4302 data
= bfd_getl16 (pcl_ptr
+ DST_S_W_PCLINE_UNSWORD
);
4305 vms_debug2 ((4, "DST__K_TERM_W: %d\n", data
));
4309 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4312 vms_debug2 ((4, "DST__K_TERM_L: %d\n", data
));
4315 case DST__K_SET_ABS_PC
:
4316 data
= bfd_getl32 (pcl_ptr
+ DST_S_L_PCLINE_UNSLONG
);
4319 vms_debug2 ((4, "DST__K_SET_ABS_PC: 0x%x\n", data
));
4328 vms_debug2 ((4, "bump pc to 0x%lx and line to %d\n",
4329 (unsigned long)curr_pc
, curr_linenum
));
4333 (*_bfd_error_handler
) (_("unknown line command %d"),
4340 if ((curr_linenum
!= prev_linum
&& curr_pc
!= prev_pc
)
4342 || cmd
== DST__K_DELTA_PC_L
4343 || cmd
== DST__K_DELTA_PC_W
)
4345 line
= (struct lineinfo
*)
4346 bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4347 line
->address
= curr_pc
;
4348 line
->line
= curr_linenum
;
4350 curr_line
->next
= line
;
4353 prev_linum
= curr_linenum
;
4355 vms_debug2 ((4, "-> correlate pc 0x%lx with line %d\n",
4356 (unsigned long)curr_pc
, curr_linenum
));
4359 pcl_ptr
+= cmd_length
;
4363 case 0x17: /* Undocumented type used by DEC C to declare equates. */
4364 vms_debug2 ((3, "undocumented type 0x17\n"));
4368 vms_debug2 ((3, "ignoring record\n"));
4376 /* Finalize tables with EOL marker. */
4377 srec
= (struct srecinfo
*) bfd_zalloc (abfd
, sizeof (struct srecinfo
));
4378 srec
->line
= (unsigned int) -1;
4379 srec
->srec
= (unsigned int) -1;
4380 curr_srec
->next
= srec
;
4382 line
= (struct lineinfo
*) bfd_zalloc (abfd
, sizeof (struct lineinfo
));
4383 line
->line
= (unsigned int) -1;
4384 line
->address
= (bfd_vma
) -1;
4385 curr_line
->next
= line
;
4387 /* Advertise that this module has been parsed. This is needed
4388 because parsing can be either performed at module creation
4389 or deferred until debug info is consumed. */
4390 SET_MODULE_PARSED (module
);
4393 /* Build the list of modules for the specified BFD. */
4395 static struct module
*
4396 build_module_list (bfd
*abfd
)
4398 struct module
*module
, *list
= NULL
;
4401 if ((dmt
= bfd_get_section_by_name (abfd
, "$DMT$")))
4403 /* We have a DMT section so this must be an image. Parse the
4404 section and build the list of modules. This is sufficient
4405 since we can compute the start address and the end address
4406 of every module from the section contents. */
4407 bfd_size_type size
= bfd_get_section_size (dmt
);
4408 unsigned char *ptr
, *end
;
4410 ptr
= (unsigned char *) bfd_alloc (abfd
, size
);
4414 if (! bfd_get_section_contents (abfd
, dmt
, ptr
, 0, size
))
4417 vms_debug2 ((2, "DMT\n"));
4423 /* Each header declares a module with its start offset and size
4424 of debug info in the DST section, as well as the count of
4425 program sections (i.e. address spans) it contains. */
4426 int modbeg
= bfd_getl32 (ptr
+ DBG_S_L_DMT_MODBEG
);
4427 int msize
= bfd_getl32 (ptr
+ DBG_S_L_DST_SIZE
);
4428 int count
= bfd_getl16 (ptr
+ DBG_S_W_DMT_PSECT_COUNT
);
4429 ptr
+= DBG_S_C_DMT_HEADER_SIZE
;
4431 vms_debug2 ((3, "module: modbeg = %d, size = %d, count = %d\n",
4432 modbeg
, msize
, count
));
4434 /* We create a 'module' structure for each program section since
4435 we only support contiguous addresses in a 'module' structure.
4436 As a consequence, the actual debug info in the DST section is
4437 shared and can be parsed multiple times; that doesn't seem to
4438 cause problems in practice. */
4441 int start
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_START
);
4442 int length
= bfd_getl32 (ptr
+ DBG_S_L_DMT_PSECT_LENGTH
);
4443 module
= new_module (abfd
);
4444 module
->modbeg
= modbeg
;
4445 module
->size
= msize
;
4446 module
->low
= start
;
4447 module
->high
= start
+ length
;
4448 module
->next
= list
;
4450 ptr
+= DBG_S_C_DMT_PSECT_SIZE
;
4452 vms_debug2 ((4, "section: start = 0x%x, length = %d\n",
4459 /* We don't have a DMT section so this must be an object. Parse
4460 the module right now in order to compute its start address and
4462 module
= new_module (abfd
);
4463 parse_module (abfd
, module
, PRIV (dst_section
)->contents
, -1);
4470 /* Calculate and return the name of the source file and the line nearest
4471 to the wanted location in the specified module. */
4474 module_find_nearest_line (bfd
*abfd
, struct module
*module
, bfd_vma addr
,
4475 const char **file
, const char **func
,
4478 struct funcinfo
*funcinfo
;
4479 struct lineinfo
*lineinfo
;
4480 struct srecinfo
*srecinfo
;
4481 bfd_boolean ret
= FALSE
;
4483 /* Parse this module if that was not done at module creation. */
4484 if (! IS_MODULE_PARSED (module
))
4486 unsigned int size
= module
->size
;
4487 unsigned int modbeg
= PRIV (dst_section
)->filepos
+ module
->modbeg
;
4488 unsigned char *buffer
= (unsigned char *) bfd_malloc (module
->size
);
4490 if (bfd_seek (abfd
, modbeg
, SEEK_SET
) != 0
4491 || bfd_bread (buffer
, size
, abfd
) != size
)
4493 bfd_set_error (bfd_error_no_debug_section
);
4497 parse_module (abfd
, module
, buffer
, size
);
4501 /* Find out the function (if any) that contains the address. */
4502 for (funcinfo
= module
->func_table
; funcinfo
; funcinfo
= funcinfo
->next
)
4503 if (addr
>= funcinfo
->low
&& addr
<= funcinfo
->high
)
4505 *func
= funcinfo
->name
;
4510 /* Find out the source file and the line nearest to the address. */
4511 for (lineinfo
= module
->line_table
; lineinfo
; lineinfo
= lineinfo
->next
)
4512 if (lineinfo
->next
&& addr
< lineinfo
->next
->address
)
4514 for (srecinfo
= module
->srec_table
; srecinfo
; srecinfo
= srecinfo
->next
)
4515 if (srecinfo
->next
&& lineinfo
->line
< srecinfo
->next
->line
)
4517 if (srecinfo
->sfile
> 0)
4519 *file
= module
->file_table
[srecinfo
->sfile
].name
;
4520 *line
= srecinfo
->srec
+ lineinfo
->line
- srecinfo
->line
;
4524 *file
= module
->name
;
4525 *line
= lineinfo
->line
;
4536 /* Provided a BFD, a section and an offset into the section, calculate and
4537 return the name of the source file and the line nearest to the wanted
4541 _bfd_vms_find_nearest_dst_line (bfd
*abfd
, asection
*section
,
4542 asymbol
**symbols ATTRIBUTE_UNUSED
,
4543 bfd_vma offset
, const char **file
,
4544 const char **func
, unsigned int *line
)
4546 struct module
*module
;
4548 /* What address are we looking for? */
4549 bfd_vma addr
= section
->vma
+ offset
;
4555 if (PRIV (dst_section
) == NULL
|| !(abfd
->flags
& (EXEC_P
| DYNAMIC
)))
4558 if (PRIV (modules
) == NULL
)
4560 PRIV (modules
) = build_module_list (abfd
);
4561 if (PRIV (modules
) == NULL
)
4565 for (module
= PRIV (modules
); module
; module
= module
->next
)
4566 if (addr
>= module
->low
&& addr
<= module
->high
)
4567 return module_find_nearest_line (abfd
, module
, addr
, file
, func
, line
);
4572 /* Canonicalizations. */
4573 /* Set name, value, section and flags of SYM from E. */
4576 alpha_vms_convert_symbol (bfd
*abfd
, struct vms_symbol_entry
*e
, asymbol
*sym
)
4585 flags
= BSF_NO_FLAGS
;
4591 if (e
->flags
& EGSY__V_WEAK
)
4594 if (e
->flags
& EGSY__V_DEF
)
4596 /* Symbol definition. */
4597 flags
|= BSF_GLOBAL
;
4598 if (e
->flags
& EGSY__V_NORM
)
4599 flags
|= BSF_FUNCTION
;
4601 sec
= PRIV (sections
)[e
->section
];
4605 /* Symbol reference. */
4606 sec
= bfd_und_section_ptr
;
4611 /* A universal symbol is by definition global... */
4612 flags
|= BSF_GLOBAL
;
4614 /* ...and dynamic in shared libraries. */
4615 if (abfd
->flags
& DYNAMIC
)
4616 flags
|= BSF_DYNAMIC
;
4618 if (e
->flags
& EGSY__V_WEAK
)
4621 if (!(e
->flags
& EGSY__V_DEF
))
4624 if (e
->flags
& EGSY__V_NORM
)
4625 flags
|= BSF_FUNCTION
;
4627 value
= e
->symbol_vector
;
4629 /* Adding this offset is necessary in order for GDB to
4630 read the DWARF-2 debug info from shared libraries. */
4631 if ((abfd
->flags
& DYNAMIC
) && strstr (name
, "$DWARF2.DEBUG") != 0)
4632 value
+= PRIV (symvva
);
4634 sec
= bfd_abs_section_ptr
;
4636 /* Find containing section. */
4641 for (s
= abfd
->sections
; s
; s
= s
->next
)
4645 && !(s
->flags
& SEC_COFF_SHARED_LIBRARY
)
4646 && (s
->size
> 0 || !(e
->flags
& EGSY__V_REL
)))
4670 /* Return the number of bytes required to store a vector of pointers
4671 to asymbols for all the symbols in the BFD abfd, including a
4672 terminal NULL pointer. If there are no symbols in the BFD,
4673 then return 0. If an error occurs, return -1. */
4676 alpha_vms_get_symtab_upper_bound (bfd
*abfd
)
4678 vms_debug2 ((1, "alpha_vms_get_symtab_upper_bound (%p), %d symbols\n",
4679 abfd
, PRIV (gsd_sym_count
)));
4681 return (PRIV (gsd_sym_count
) + 1) * sizeof (asymbol
*);
4684 /* Read the symbols from the BFD abfd, and fills in the vector
4685 location with pointers to the symbols and a trailing NULL.
4687 Return number of symbols read. */
4690 alpha_vms_canonicalize_symtab (bfd
*abfd
, asymbol
**symbols
)
4694 vms_debug2 ((1, "alpha_vms_canonicalize_symtab (%p, <ret>)\n", abfd
));
4696 if (PRIV (csymbols
) == NULL
)
4698 PRIV (csymbols
) = (asymbol
**) bfd_alloc
4699 (abfd
, PRIV (gsd_sym_count
) * sizeof (asymbol
*));
4701 /* Traverse table and fill symbols vector. */
4702 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4704 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
4707 sym
= bfd_make_empty_symbol (abfd
);
4708 if (sym
== NULL
|| !alpha_vms_convert_symbol (abfd
, e
, sym
))
4710 bfd_release (abfd
, PRIV (csymbols
));
4711 PRIV (csymbols
) = NULL
;
4715 PRIV (csymbols
)[i
] = sym
;
4719 if (symbols
!= NULL
)
4721 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
4722 symbols
[i
] = PRIV (csymbols
)[i
];
4726 return PRIV (gsd_sym_count
);
4729 /* Read and convert relocations from ETIR. We do it once for all sections. */
4732 alpha_vms_slurp_relocs (bfd
*abfd
)
4736 vms_debug2 ((3, "alpha_vms_slurp_relocs\n"));
4738 /* We slurp relocs only once, for all sections. */
4739 if (PRIV (reloc_done
))
4741 PRIV (reloc_done
) = TRUE
;
4743 if (alpha_vms_canonicalize_symtab (abfd
, NULL
) < 0)
4746 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
4751 unsigned char *begin
;
4754 bfd_reloc_code_real_type reloc_code
;
4760 bfd_vma cur_address
;
4762 unsigned char *cur_sym
= NULL
;
4764 bfd_vma cur_addend
= 0;
4766 /* Skip non-ETIR records. */
4767 type
= _bfd_vms_get_object_record (abfd
);
4768 if (type
== EOBJ__C_EEOM
)
4770 if (type
!= EOBJ__C_ETIR
)
4773 begin
= PRIV (recrd
.rec
) + 4;
4774 end
= PRIV (recrd
.rec
) + PRIV (recrd
.rec_size
);
4776 for (ptr
= begin
; ptr
< end
; ptr
+= length
)
4780 cmd
= bfd_getl16 (ptr
);
4781 length
= bfd_getl16 (ptr
+ 2);
4783 cur_address
= vaddr
;
4785 vms_debug2 ((4, "alpha_vms_slurp_relocs: etir %s\n",
4786 _bfd_vms_etir_name (cmd
)));
4790 case ETIR__C_STA_GBL
: /* ALPHA_R_REFLONG und_section, step 1 */
4791 /* ALPHA_R_REFQUAD und_section, step 1 */
4796 case ETIR__C_STA_PQ
: /* ALPHA_R_REF{LONG|QUAD}, others part 1 */
4797 cur_psidx
= bfd_getl32 (ptr
+ 4);
4798 cur_addend
= bfd_getl64 (ptr
+ 8);
4802 case ETIR__C_CTL_SETRB
:
4803 if (prev_cmd
!= ETIR__C_STA_PQ
)
4805 (*_bfd_error_handler
)
4806 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (prev_cmd
),
4807 _bfd_vms_etir_name (cmd
));
4810 cur_psect
= cur_psidx
;
4816 case ETIR__C_STA_LW
: /* ALPHA_R_REFLONG abs_section, step 1 */
4817 /* ALPHA_R_REFLONG und_section, step 2 */
4820 if (prev_cmd
!= ETIR__C_STA_GBL
)
4822 (*_bfd_error_handler
)
4823 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4824 _bfd_vms_etir_name (ETIR__C_STA_LW
));
4828 cur_addend
= bfd_getl32 (ptr
+ 4);
4832 case ETIR__C_STA_QW
: /* ALPHA_R_REFQUAD abs_section, step 1 */
4833 /* ALPHA_R_REFQUAD und_section, step 2 */
4834 if (prev_cmd
!= -1 && prev_cmd
!= ETIR__C_STA_GBL
)
4836 (*_bfd_error_handler
)
4837 (_("Unknown reloc %s + %s"), _bfd_vms_etir_name (cmd
),
4838 _bfd_vms_etir_name (ETIR__C_STA_QW
));
4841 cur_addend
= bfd_getl64 (ptr
+ 4);
4845 case ETIR__C_STO_LW
: /* ALPHA_R_REFLONG und_section, step 4 */
4846 /* ALPHA_R_REFLONG abs_section, step 2 */
4847 /* ALPHA_R_REFLONG others, step 2 */
4848 if (prev_cmd
!= ETIR__C_OPR_ADD
4849 && prev_cmd
!= ETIR__C_STA_LW
4850 && prev_cmd
!= ETIR__C_STA_PQ
)
4852 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4853 _bfd_vms_etir_name (prev_cmd
),
4854 _bfd_vms_etir_name (ETIR__C_STO_LW
));
4857 reloc_code
= BFD_RELOC_32
;
4860 case ETIR__C_STO_QW
: /* ALPHA_R_REFQUAD und_section, step 4 */
4861 /* ALPHA_R_REFQUAD abs_section, step 2 */
4862 if (prev_cmd
!= ETIR__C_OPR_ADD
&& prev_cmd
!= ETIR__C_STA_QW
)
4864 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4865 _bfd_vms_etir_name (prev_cmd
),
4866 _bfd_vms_etir_name (ETIR__C_STO_QW
));
4869 reloc_code
= BFD_RELOC_64
;
4872 case ETIR__C_STO_OFF
: /* ALPHA_R_REFQUAD others, step 2 */
4873 if (prev_cmd
!= ETIR__C_STA_PQ
)
4875 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4876 _bfd_vms_etir_name (prev_cmd
),
4877 _bfd_vms_etir_name (ETIR__C_STO_OFF
));
4880 reloc_code
= BFD_RELOC_64
;
4883 case ETIR__C_OPR_ADD
: /* ALPHA_R_REFLONG und_section, step 3 */
4884 /* ALPHA_R_REFQUAD und_section, step 3 */
4885 if (prev_cmd
!= ETIR__C_STA_LW
&& prev_cmd
!= ETIR__C_STA_QW
)
4887 (*_bfd_error_handler
) (_("Unknown reloc %s + %s"),
4888 _bfd_vms_etir_name (prev_cmd
),
4889 _bfd_vms_etir_name (ETIR__C_OPR_ADD
));
4892 prev_cmd
= ETIR__C_OPR_ADD
;
4895 case ETIR__C_STO_CA
: /* ALPHA_R_CODEADDR */
4896 reloc_code
= BFD_RELOC_ALPHA_CODEADDR
;
4900 case ETIR__C_STO_GBL
: /* ALPHA_R_REFQUAD und_section */
4901 reloc_code
= BFD_RELOC_64
;
4905 case ETIR__C_STO_GBL_LW
: /* ALPHA_R_REFLONG und_section */
4906 reloc_code
= BFD_RELOC_32
;
4910 case ETIR__C_STC_LP_PSB
: /* ALPHA_R_LINKAGE */
4911 reloc_code
= BFD_RELOC_ALPHA_LINKAGE
;
4915 case ETIR__C_STC_NOP_GBL
: /* ALPHA_R_NOP */
4916 reloc_code
= BFD_RELOC_ALPHA_NOP
;
4919 case ETIR__C_STC_BSR_GBL
: /* ALPHA_R_BSR */
4920 reloc_code
= BFD_RELOC_ALPHA_BSR
;
4923 case ETIR__C_STC_LDA_GBL
: /* ALPHA_R_LDA */
4924 reloc_code
= BFD_RELOC_ALPHA_LDA
;
4927 case ETIR__C_STC_BOH_GBL
: /* ALPHA_R_BOH */
4928 reloc_code
= BFD_RELOC_ALPHA_BOH
;
4932 cur_sym
= ptr
+ 4 + 32;
4933 cur_address
= bfd_getl64 (ptr
+ 4 + 8);
4934 cur_addend
= bfd_getl64 (ptr
+ 4 + 24);
4937 case ETIR__C_STO_IMM
:
4938 vaddr
+= bfd_getl32 (ptr
+ 4);
4942 (*_bfd_error_handler
) (_("Unknown reloc %s"),
4943 _bfd_vms_etir_name (cmd
));
4949 struct vms_section_data_struct
*vms_sec
;
4952 /* Get section to which the relocation applies. */
4953 if (cur_psect
< 0 || cur_psect
> (int)PRIV (section_count
))
4955 (*_bfd_error_handler
) (_("Invalid section index in ETIR"));
4958 sec
= PRIV (sections
)[cur_psect
];
4959 vms_sec
= vms_section_data (sec
);
4961 /* Allocate a reloc entry. */
4962 if (sec
->reloc_count
>= vms_sec
->reloc_max
)
4964 if (vms_sec
->reloc_max
== 0)
4966 vms_sec
->reloc_max
= 64;
4967 sec
->relocation
= bfd_zmalloc
4968 (vms_sec
->reloc_max
* sizeof (arelent
));
4972 vms_sec
->reloc_max
*= 2;
4973 sec
->relocation
= bfd_realloc
4974 (sec
->relocation
, vms_sec
->reloc_max
* sizeof (arelent
));
4977 reloc
= &sec
->relocation
[sec
->reloc_count
];
4980 reloc
->howto
= bfd_reloc_type_lookup (abfd
, reloc_code
);
4982 if (cur_sym
!= NULL
)
4985 unsigned int symlen
= *cur_sym
;
4988 /* Linear search. */
4993 for (j
= 0; j
< PRIV (gsd_sym_count
); j
++)
4994 if (PRIV (syms
)[j
]->namelen
== symlen
4995 && memcmp (PRIV (syms
)[j
]->name
, cur_sym
, symlen
) == 0)
4997 sym
= &PRIV (csymbols
)[j
];
5002 (*_bfd_error_handler
) (_("Unknown symbol in command %s"),
5003 _bfd_vms_etir_name (cmd
));
5004 reloc
->sym_ptr_ptr
= NULL
;
5007 reloc
->sym_ptr_ptr
= sym
;
5009 else if (cur_psidx
>= 0)
5010 reloc
->sym_ptr_ptr
=
5011 PRIV (sections
)[cur_psidx
]->symbol_ptr_ptr
;
5013 reloc
->sym_ptr_ptr
= NULL
;
5015 reloc
->address
= cur_address
;
5016 reloc
->addend
= cur_addend
;
5018 vaddr
+= bfd_get_reloc_size (reloc
->howto
);
5027 vms_debug2 ((3, "alpha_vms_slurp_relocs: result = TRUE\n"));
5032 /* Return the number of bytes required to store the relocation
5033 information associated with the given section. */
5036 alpha_vms_get_reloc_upper_bound (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*section
)
5038 alpha_vms_slurp_relocs (abfd
);
5040 return (section
->reloc_count
+ 1) * sizeof (arelent
*);
5043 /* Convert relocations from VMS (external) form into BFD internal
5044 form. Return the number of relocations. */
5047 alpha_vms_canonicalize_reloc (bfd
*abfd
, asection
*section
, arelent
**relptr
,
5048 asymbol
**symbols ATTRIBUTE_UNUSED
)
5053 if (!alpha_vms_slurp_relocs (abfd
))
5056 count
= section
->reloc_count
;
5057 tblptr
= section
->relocation
;
5060 *relptr
++ = tblptr
++;
5062 *relptr
= (arelent
*) NULL
;
5063 return section
->reloc_count
;
5066 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
5068 /* How to process the various reloc types. */
5070 static bfd_reloc_status_type
5071 reloc_nil (bfd
* abfd ATTRIBUTE_UNUSED
,
5072 arelent
*reloc ATTRIBUTE_UNUSED
,
5073 asymbol
*sym ATTRIBUTE_UNUSED
,
5074 void * data ATTRIBUTE_UNUSED
,
5075 asection
*sec ATTRIBUTE_UNUSED
,
5076 bfd
*output_bfd ATTRIBUTE_UNUSED
,
5077 char **error_message ATTRIBUTE_UNUSED
)
5080 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
5081 vms_debug (2, "In section %s, symbol %s\n",
5082 sec
->name
, sym
->name
);
5083 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
5084 reloc
->sym_ptr_ptr
[0]->name
,
5085 (unsigned long)reloc
->address
,
5086 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
5087 vms_debug (2, "data at %p\n", data
);
5088 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
5091 return bfd_reloc_ok
;
5094 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
5095 from smaller values. Start with zero, widen, *then* decrement. */
5096 #define MINUS_ONE (((bfd_vma)0) - 1)
5098 static reloc_howto_type alpha_howto_table
[] =
5100 HOWTO (ALPHA_R_IGNORE
, /* Type. */
5101 0, /* Rightshift. */
5102 0, /* Size (0 = byte, 1 = short, 2 = long). */
5104 TRUE
, /* PC relative. */
5106 complain_overflow_dont
,/* Complain_on_overflow. */
5107 reloc_nil
, /* Special_function. */
5108 "IGNORE", /* Name. */
5109 TRUE
, /* Partial_inplace. */
5110 0, /* Source mask */
5112 TRUE
), /* PC rel offset. */
5114 /* A 64 bit reference to a symbol. */
5115 HOWTO (ALPHA_R_REFQUAD
, /* Type. */
5116 0, /* Rightshift. */
5117 4, /* Size (0 = byte, 1 = short, 2 = long). */
5119 FALSE
, /* PC relative. */
5121 complain_overflow_bitfield
, /* Complain_on_overflow. */
5122 reloc_nil
, /* Special_function. */
5123 "REFQUAD", /* Name. */
5124 TRUE
, /* Partial_inplace. */
5125 MINUS_ONE
, /* Source mask. */
5126 MINUS_ONE
, /* Dest mask. */
5127 FALSE
), /* PC rel offset. */
5129 /* A 21 bit branch. The native assembler generates these for
5130 branches within the text segment, and also fills in the PC
5131 relative offset in the instruction. */
5132 HOWTO (ALPHA_R_BRADDR
, /* Type. */
5133 2, /* Rightshift. */
5134 2, /* Size (0 = byte, 1 = short, 2 = long). */
5136 TRUE
, /* PC relative. */
5138 complain_overflow_signed
, /* Complain_on_overflow. */
5139 reloc_nil
, /* Special_function. */
5140 "BRADDR", /* Name. */
5141 TRUE
, /* Partial_inplace. */
5142 0x1fffff, /* Source mask. */
5143 0x1fffff, /* Dest mask. */
5144 FALSE
), /* PC rel offset. */
5146 /* A hint for a jump to a register. */
5147 HOWTO (ALPHA_R_HINT
, /* Type. */
5148 2, /* Rightshift. */
5149 1, /* Size (0 = byte, 1 = short, 2 = long). */
5151 TRUE
, /* PC relative. */
5153 complain_overflow_dont
,/* Complain_on_overflow. */
5154 reloc_nil
, /* Special_function. */
5156 TRUE
, /* Partial_inplace. */
5157 0x3fff, /* Source mask. */
5158 0x3fff, /* Dest mask. */
5159 FALSE
), /* PC rel offset. */
5161 /* 16 bit PC relative offset. */
5162 HOWTO (ALPHA_R_SREL16
, /* Type. */
5163 0, /* Rightshift. */
5164 1, /* Size (0 = byte, 1 = short, 2 = long). */
5166 TRUE
, /* PC relative. */
5168 complain_overflow_signed
, /* Complain_on_overflow. */
5169 reloc_nil
, /* Special_function. */
5170 "SREL16", /* Name. */
5171 TRUE
, /* Partial_inplace. */
5172 0xffff, /* Source mask. */
5173 0xffff, /* Dest mask. */
5174 FALSE
), /* PC rel offset. */
5176 /* 32 bit PC relative offset. */
5177 HOWTO (ALPHA_R_SREL32
, /* Type. */
5178 0, /* Rightshift. */
5179 2, /* Size (0 = byte, 1 = short, 2 = long). */
5181 TRUE
, /* PC relative. */
5183 complain_overflow_signed
, /* Complain_on_overflow. */
5184 reloc_nil
, /* Special_function. */
5185 "SREL32", /* Name. */
5186 TRUE
, /* Partial_inplace. */
5187 0xffffffff, /* Source mask. */
5188 0xffffffff, /* Dest mask. */
5189 FALSE
), /* PC rel offset. */
5191 /* A 64 bit PC relative offset. */
5192 HOWTO (ALPHA_R_SREL64
, /* Type. */
5193 0, /* Rightshift. */
5194 4, /* Size (0 = byte, 1 = short, 2 = long). */
5196 TRUE
, /* PC relative. */
5198 complain_overflow_signed
, /* Complain_on_overflow. */
5199 reloc_nil
, /* Special_function. */
5200 "SREL64", /* Name. */
5201 TRUE
, /* Partial_inplace. */
5202 MINUS_ONE
, /* Source mask. */
5203 MINUS_ONE
, /* Dest mask. */
5204 FALSE
), /* PC rel offset. */
5206 /* Push a value on the reloc evaluation stack. */
5207 HOWTO (ALPHA_R_OP_PUSH
, /* Type. */
5208 0, /* Rightshift. */
5209 0, /* Size (0 = byte, 1 = short, 2 = long). */
5211 FALSE
, /* PC relative. */
5213 complain_overflow_dont
,/* Complain_on_overflow. */
5214 reloc_nil
, /* Special_function. */
5215 "OP_PUSH", /* Name. */
5216 FALSE
, /* Partial_inplace. */
5217 0, /* Source mask. */
5219 FALSE
), /* PC rel offset. */
5221 /* Store the value from the stack at the given address. Store it in
5222 a bitfield of size r_size starting at bit position r_offset. */
5223 HOWTO (ALPHA_R_OP_STORE
, /* Type. */
5224 0, /* Rightshift. */
5225 4, /* Size (0 = byte, 1 = short, 2 = long). */
5227 FALSE
, /* PC relative. */
5229 complain_overflow_dont
,/* Complain_on_overflow. */
5230 reloc_nil
, /* Special_function. */
5231 "OP_STORE", /* Name. */
5232 FALSE
, /* Partial_inplace. */
5233 0, /* Source mask. */
5234 MINUS_ONE
, /* Dest mask. */
5235 FALSE
), /* PC rel offset. */
5237 /* Subtract the reloc address from the value on the top of the
5238 relocation stack. */
5239 HOWTO (ALPHA_R_OP_PSUB
, /* Type. */
5240 0, /* Rightshift. */
5241 0, /* Size (0 = byte, 1 = short, 2 = long). */
5243 FALSE
, /* PC relative. */
5245 complain_overflow_dont
,/* Complain_on_overflow. */
5246 reloc_nil
, /* Special_function. */
5247 "OP_PSUB", /* Name. */
5248 FALSE
, /* Partial_inplace. */
5249 0, /* Source mask. */
5251 FALSE
), /* PC rel offset. */
5253 /* Shift the value on the top of the relocation stack right by the
5255 HOWTO (ALPHA_R_OP_PRSHIFT
, /* Type. */
5256 0, /* Rightshift. */
5257 0, /* Size (0 = byte, 1 = short, 2 = long). */
5259 FALSE
, /* PC relative. */
5261 complain_overflow_dont
,/* Complain_on_overflow. */
5262 reloc_nil
, /* Special_function. */
5263 "OP_PRSHIFT", /* Name. */
5264 FALSE
, /* Partial_inplace. */
5265 0, /* Source mask. */
5267 FALSE
), /* PC rel offset. */
5269 /* Hack. Linkage is done by linker. */
5270 HOWTO (ALPHA_R_LINKAGE
, /* Type. */
5271 0, /* Rightshift. */
5272 8, /* Size (0 = byte, 1 = short, 2 = long). */
5274 FALSE
, /* PC relative. */
5276 complain_overflow_dont
,/* Complain_on_overflow. */
5277 reloc_nil
, /* Special_function. */
5278 "LINKAGE", /* Name. */
5279 FALSE
, /* Partial_inplace. */
5280 0, /* Source mask. */
5282 FALSE
), /* PC rel offset. */
5284 /* A 32 bit reference to a symbol. */
5285 HOWTO (ALPHA_R_REFLONG
, /* Type. */
5286 0, /* Rightshift. */
5287 2, /* Size (0 = byte, 1 = short, 2 = long). */
5289 FALSE
, /* PC relative. */
5291 complain_overflow_bitfield
, /* Complain_on_overflow. */
5292 reloc_nil
, /* Special_function. */
5293 "REFLONG", /* Name. */
5294 TRUE
, /* Partial_inplace. */
5295 0xffffffff, /* Source mask. */
5296 0xffffffff, /* Dest mask. */
5297 FALSE
), /* PC rel offset. */
5299 /* A 64 bit reference to a procedure, written as 32 bit value. */
5300 HOWTO (ALPHA_R_CODEADDR
, /* Type. */
5301 0, /* Rightshift. */
5302 4, /* Size (0 = byte, 1 = short, 2 = long). */
5304 FALSE
, /* PC relative. */
5306 complain_overflow_signed
,/* Complain_on_overflow. */
5307 reloc_nil
, /* Special_function. */
5308 "CODEADDR", /* Name. */
5309 FALSE
, /* Partial_inplace. */
5310 0xffffffff, /* Source mask. */
5311 0xffffffff, /* Dest mask. */
5312 FALSE
), /* PC rel offset. */
5314 HOWTO (ALPHA_R_NOP
, /* Type. */
5315 0, /* Rightshift. */
5316 3, /* Size (0 = byte, 1 = short, 2 = long). */
5318 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
5319 because the calculations for the 3 relocations are the same.
5320 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
5321 TRUE
, /* PC relative. */
5323 complain_overflow_dont
,/* Complain_on_overflow. */
5324 reloc_nil
, /* Special_function. */
5326 FALSE
, /* Partial_inplace. */
5327 0xffffffff, /* Source mask. */
5328 0xffffffff, /* Dest mask. */
5329 FALSE
), /* PC rel offset. */
5331 HOWTO (ALPHA_R_BSR
, /* Type. */
5332 0, /* Rightshift. */
5333 3, /* Size (0 = byte, 1 = short, 2 = long). */
5335 TRUE
, /* PC relative. */
5337 complain_overflow_dont
,/* Complain_on_overflow. */
5338 reloc_nil
, /* Special_function. */
5340 FALSE
, /* Partial_inplace. */
5341 0xffffffff, /* Source mask. */
5342 0xffffffff, /* Dest mask. */
5343 FALSE
), /* PC rel offset. */
5345 HOWTO (ALPHA_R_LDA
, /* Type. */
5346 0, /* Rightshift. */
5347 3, /* Size (0 = byte, 1 = short, 2 = long). */
5349 FALSE
, /* PC relative. */
5351 complain_overflow_dont
,/* Complain_on_overflow. */
5352 reloc_nil
, /* Special_function. */
5354 FALSE
, /* Partial_inplace. */
5355 0xffffffff, /* Source mask. */
5356 0xffffffff, /* Dest mask. */
5357 FALSE
), /* PC rel offset. */
5359 HOWTO (ALPHA_R_BOH
, /* Type. */
5360 0, /* Rightshift. */
5361 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
5363 TRUE
, /* PC relative. */
5365 complain_overflow_dont
,/* Complain_on_overflow. */
5366 reloc_nil
, /* Special_function. */
5368 FALSE
, /* Partial_inplace. */
5369 0xffffffff, /* Source mask. */
5370 0xffffffff, /* Dest mask. */
5371 FALSE
), /* PC rel offset. */
5374 /* Return a pointer to a howto structure which, when invoked, will perform
5375 the relocation code on data from the architecture noted. */
5377 static const struct reloc_howto_struct
*
5378 alpha_vms_bfd_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
5379 bfd_reloc_code_real_type code
)
5383 vms_debug2 ((1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd
, code
));
5387 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
5388 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
5389 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
5390 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
5391 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
5392 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
5393 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
5394 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
5395 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
5396 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
5397 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
5398 case BFD_RELOC_ALPHA_NOP
: alpha_type
= ALPHA_R_NOP
; break;
5399 case BFD_RELOC_ALPHA_BSR
: alpha_type
= ALPHA_R_BSR
; break;
5400 case BFD_RELOC_ALPHA_LDA
: alpha_type
= ALPHA_R_LDA
; break;
5401 case BFD_RELOC_ALPHA_BOH
: alpha_type
= ALPHA_R_BOH
; break;
5403 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
5406 vms_debug2 ((2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
));
5407 return & alpha_howto_table
[alpha_type
];
5410 static reloc_howto_type
*
5411 alpha_vms_bfd_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
5417 i
< sizeof (alpha_howto_table
) / sizeof (alpha_howto_table
[0]);
5419 if (alpha_howto_table
[i
].name
!= NULL
5420 && strcasecmp (alpha_howto_table
[i
].name
, r_name
) == 0)
5421 return &alpha_howto_table
[i
];
5427 alpha_vms_get_synthetic_symtab (bfd
*abfd
,
5428 long symcount ATTRIBUTE_UNUSED
,
5429 asymbol
**usyms ATTRIBUTE_UNUSED
,
5430 long dynsymcount ATTRIBUTE_UNUSED
,
5431 asymbol
**dynsyms ATTRIBUTE_UNUSED
,
5438 syms
= (asymbol
*) bfd_malloc (PRIV (norm_sym_count
) * sizeof (asymbol
));
5443 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
5445 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
5456 flags
= BSF_LOCAL
| BSF_SYNTHETIC
;
5462 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5464 value
= e
->code_value
;
5465 sec
= PRIV (sections
)[e
->code_section
];
5472 if ((e
->flags
& EGSY__V_DEF
) && (e
->flags
& EGSY__V_NORM
))
5477 value
= e
->code_value
;
5479 /* Find containing section. */
5480 for (s
= abfd
->sections
; s
; s
= s
->next
)
5484 && !(s
->flags
& SEC_COFF_SHARED_LIBRARY
)
5485 && (s
->size
> 0 || !(e
->flags
& EGSY__V_REL
)))
5502 sname
= bfd_alloc (abfd
, l
+ 5);
5505 memcpy (sname
, name
, l
);
5506 memcpy (sname
+ l
, "..en", 5);
5513 sym
->udata
.p
= NULL
;
5522 vms_time_to_str (unsigned char *buf
)
5524 time_t t
= vms_rawtime_to_time_t (buf
);
5525 char *res
= ctime (&t
);
5528 res
= "*invalid time*";
5535 evax_bfd_print_emh (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5537 struct vms_emh_common
*emh
= (struct vms_emh_common
*)rec
;
5538 unsigned int subtype
;
5540 subtype
= (unsigned)bfd_getl16 (emh
->subtyp
);
5542 fprintf (file
, _(" EMH %u (len=%u): "), subtype
, rec_len
);
5548 struct vms_emh_mhd
*mhd
= (struct vms_emh_mhd
*)rec
;
5551 fprintf (file
, _("Module header\n"));
5552 fprintf (file
, _(" structure level: %u\n"), mhd
->strlvl
);
5553 fprintf (file
, _(" max record size: %u\n"),
5554 (unsigned)bfd_getl32 (mhd
->recsiz
));
5555 name
= (char *)(mhd
+ 1);
5556 fprintf (file
, _(" module name : %.*s\n"), name
[0], name
+ 1);
5557 name
+= name
[0] + 1;
5558 fprintf (file
, _(" module version : %.*s\n"), name
[0], name
+ 1);
5559 name
+= name
[0] + 1;
5560 fprintf (file
, _(" compile date : %.17s\n"), name
);
5565 fprintf (file
, _("Language Processor Name\n"));
5566 fprintf (file
, _(" language name: %.*s\n"),
5567 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5568 (char *)rec
+ sizeof (struct vms_emh_common
));
5573 fprintf (file
, _("Source Files Header\n"));
5574 fprintf (file
, _(" file: %.*s\n"),
5575 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5576 (char *)rec
+ sizeof (struct vms_emh_common
));
5581 fprintf (file
, _("Title Text Header\n"));
5582 fprintf (file
, _(" title: %.*s\n"),
5583 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5584 (char *)rec
+ sizeof (struct vms_emh_common
));
5589 fprintf (file
, _("Copyright Header\n"));
5590 fprintf (file
, _(" copyright: %.*s\n"),
5591 (int)(rec_len
- sizeof (struct vms_emh_common
)),
5592 (char *)rec
+ sizeof (struct vms_emh_common
));
5596 fprintf (file
, _("unhandled emh subtype %u\n"), subtype
);
5602 evax_bfd_print_eeom (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5604 struct vms_eeom
*eeom
= (struct vms_eeom
*)rec
;
5606 fprintf (file
, _(" EEOM (len=%u):\n"), rec_len
);
5607 fprintf (file
, _(" number of cond linkage pairs: %u\n"),
5608 (unsigned)bfd_getl32 (eeom
->total_lps
));
5609 fprintf (file
, _(" completion code: %u\n"),
5610 (unsigned)bfd_getl16 (eeom
->comcod
));
5613 fprintf (file
, _(" transfer addr flags: 0x%02x\n"), eeom
->tfrflg
);
5614 fprintf (file
, _(" transfer addr psect: %u\n"),
5615 (unsigned)bfd_getl32 (eeom
->psindx
));
5616 fprintf (file
, _(" transfer address : 0x%08x\n"),
5617 (unsigned)bfd_getl32 (eeom
->tfradr
));
5622 exav_bfd_print_egsy_flags (unsigned int flags
, FILE *file
)
5624 if (flags
& EGSY__V_WEAK
)
5625 fputs (_(" WEAK"), file
);
5626 if (flags
& EGSY__V_DEF
)
5627 fputs (_(" DEF"), file
);
5628 if (flags
& EGSY__V_UNI
)
5629 fputs (_(" UNI"), file
);
5630 if (flags
& EGSY__V_REL
)
5631 fputs (_(" REL"), file
);
5632 if (flags
& EGSY__V_COMM
)
5633 fputs (_(" COMM"), file
);
5634 if (flags
& EGSY__V_VECEP
)
5635 fputs (_(" VECEP"), file
);
5636 if (flags
& EGSY__V_NORM
)
5637 fputs (_(" NORM"), file
);
5638 if (flags
& EGSY__V_QUAD_VAL
)
5639 fputs (_(" QVAL"), file
);
5643 evax_bfd_print_egsd (FILE *file
, unsigned char *rec
, unsigned int rec_len
)
5645 unsigned int off
= sizeof (struct vms_egsd
);
5648 fprintf (file
, _(" EGSD (len=%u):\n"), rec_len
);
5651 for (off
= sizeof (struct vms_egsd
); off
< rec_len
; )
5653 struct vms_egsd_entry
*e
= (struct vms_egsd_entry
*)(rec
+ off
);
5657 type
= (unsigned)bfd_getl16 (e
->gsdtyp
);
5658 len
= (unsigned)bfd_getl16 (e
->gsdsiz
);
5660 fprintf (file
, _(" EGSD entry %2u (type: %u, len: %u): "),
5668 struct vms_egps
*egps
= (struct vms_egps
*)e
;
5669 unsigned int flags
= bfd_getl16 (egps
->flags
);
5672 fprintf (file
, _("PSC - Program section definition\n"));
5673 fprintf (file
, _(" alignment : 2**%u\n"), egps
->align
);
5674 fprintf (file
, _(" flags : 0x%04x"), flags
);
5675 if (flags
& EGPS__V_PIC
)
5676 fputs (_(" PIC"), file
);
5677 if (flags
& EGPS__V_LIB
)
5678 fputs (_(" LIB"), file
);
5679 if (flags
& EGPS__V_OVR
)
5680 fputs (_(" OVR"), file
);
5681 if (flags
& EGPS__V_REL
)
5682 fputs (_(" REL"), file
);
5683 if (flags
& EGPS__V_GBL
)
5684 fputs (_(" GBL"), file
);
5685 if (flags
& EGPS__V_SHR
)
5686 fputs (_(" SHR"), file
);
5687 if (flags
& EGPS__V_EXE
)
5688 fputs (_(" EXE"), file
);
5689 if (flags
& EGPS__V_RD
)
5690 fputs (_(" RD"), file
);
5691 if (flags
& EGPS__V_WRT
)
5692 fputs (_(" WRT"), file
);
5693 if (flags
& EGPS__V_VEC
)
5694 fputs (_(" VEC"), file
);
5695 if (flags
& EGPS__V_NOMOD
)
5696 fputs (_(" NOMOD"), file
);
5697 if (flags
& EGPS__V_COM
)
5698 fputs (_(" COM"), file
);
5699 if (flags
& EGPS__V_ALLOC_64BIT
)
5700 fputs (_(" 64B"), file
);
5702 l
= bfd_getl32 (egps
->alloc
);
5703 fprintf (file
, _(" alloc (len): %u (0x%08x)\n"), l
, l
);
5704 fprintf (file
, _(" name : %.*s\n"),
5705 egps
->namlng
, egps
->name
);
5710 struct vms_egsy
*egsy
= (struct vms_egsy
*)e
;
5711 unsigned int flags
= bfd_getl16 (egsy
->flags
);
5713 if (flags
& EGSY__V_DEF
)
5715 struct vms_esdf
*esdf
= (struct vms_esdf
*)e
;
5717 fprintf (file
, _("SYM - Global symbol definition\n"));
5718 fprintf (file
, _(" flags: 0x%04x"), flags
);
5719 exav_bfd_print_egsy_flags (flags
, file
);
5721 fprintf (file
, _(" psect offset: 0x%08x\n"),
5722 (unsigned)bfd_getl32 (esdf
->value
));
5723 if (flags
& EGSY__V_NORM
)
5725 fprintf (file
, _(" code address: 0x%08x\n"),
5726 (unsigned)bfd_getl32 (esdf
->code_address
));
5727 fprintf (file
, _(" psect index for entry point : %u\n"),
5728 (unsigned)bfd_getl32 (esdf
->ca_psindx
));
5730 fprintf (file
, _(" psect index : %u\n"),
5731 (unsigned)bfd_getl32 (esdf
->psindx
));
5732 fprintf (file
, _(" name : %.*s\n"),
5733 esdf
->namlng
, esdf
->name
);
5737 struct vms_esrf
*esrf
= (struct vms_esrf
*)e
;
5739 fprintf (file
, _("SYM - Global symbol reference\n"));
5740 fprintf (file
, _(" name : %.*s\n"),
5741 esrf
->namlng
, esrf
->name
);
5747 struct vms_egst
*egst
= (struct vms_egst
*)e
;
5748 unsigned int flags
= bfd_getl16 (egst
->header
.flags
);
5750 fprintf (file
, _("SYMG - Universal symbol definition\n"));
5751 fprintf (file
, _(" flags: 0x%04x"), flags
);
5752 exav_bfd_print_egsy_flags (flags
, file
);
5754 fprintf (file
, _(" symbol vector offset: 0x%08x\n"),
5755 (unsigned)bfd_getl32 (egst
->value
));
5756 fprintf (file
, _(" entry point: 0x%08x\n"),
5757 (unsigned)bfd_getl32 (egst
->lp_1
));
5758 fprintf (file
, _(" proc descr : 0x%08x\n"),
5759 (unsigned)bfd_getl32 (egst
->lp_2
));
5760 fprintf (file
, _(" psect index: %u\n"),
5761 (unsigned)bfd_getl32 (egst
->psindx
));
5762 fprintf (file
, _(" name : %.*s\n"),
5763 egst
->namlng
, egst
->name
);
5768 struct vms_esdfv
*esdfv
= (struct vms_esdfv
*)e
;
5769 unsigned int flags
= bfd_getl16 (esdfv
->flags
);
5771 fprintf (file
, _("SYMV - Vectored symbol definition\n"));
5772 fprintf (file
, _(" flags: 0x%04x"), flags
);
5773 exav_bfd_print_egsy_flags (flags
, file
);
5775 fprintf (file
, _(" vector : 0x%08x\n"),
5776 (unsigned)bfd_getl32 (esdfv
->vector
));
5777 fprintf (file
, _(" psect offset: %u\n"),
5778 (unsigned)bfd_getl32 (esdfv
->value
));
5779 fprintf (file
, _(" psect index : %u\n"),
5780 (unsigned)bfd_getl32 (esdfv
->psindx
));
5781 fprintf (file
, _(" name : %.*s\n"),
5782 esdfv
->namlng
, esdfv
->name
);
5787 struct vms_esdfm
*esdfm
= (struct vms_esdfm
*)e
;
5788 unsigned int flags
= bfd_getl16 (esdfm
->flags
);
5790 fprintf (file
, _("SYMM - Global symbol definition with version\n"));
5791 fprintf (file
, _(" flags: 0x%04x"), flags
);
5792 exav_bfd_print_egsy_flags (flags
, file
);
5794 fprintf (file
, _(" version mask: 0x%08x\n"),
5795 (unsigned)bfd_getl32 (esdfm
->version_mask
));
5796 fprintf (file
, _(" psect offset: %u\n"),
5797 (unsigned)bfd_getl32 (esdfm
->value
));
5798 fprintf (file
, _(" psect index : %u\n"),
5799 (unsigned)bfd_getl32 (esdfm
->psindx
));
5800 fprintf (file
, _(" name : %.*s\n"),
5801 esdfm
->namlng
, esdfm
->name
);
5805 fprintf (file
, _("unhandled egsd entry type %u\n"), type
);
5813 evax_bfd_print_hex (FILE *file
, const char *pfx
,
5814 const unsigned char *buf
, unsigned int len
)
5820 for (i
= 0; i
< len
; i
++)
5824 fprintf (file
, " %02x", buf
[i
]);
5837 evax_bfd_print_etir_stc_ir (FILE *file
, const unsigned char *buf
, int is_ps
)
5839 fprintf (file
, _(" linkage index: %u, replacement insn: 0x%08x\n"),
5840 (unsigned)bfd_getl32 (buf
),
5841 (unsigned)bfd_getl32 (buf
+ 16));
5842 fprintf (file
, _(" psect idx 1: %u, offset 1: 0x%08x %08x\n"),
5843 (unsigned)bfd_getl32 (buf
+ 4),
5844 (unsigned)bfd_getl32 (buf
+ 12),
5845 (unsigned)bfd_getl32 (buf
+ 8));
5846 fprintf (file
, _(" psect idx 2: %u, offset 2: 0x%08x %08x\n"),
5847 (unsigned)bfd_getl32 (buf
+ 20),
5848 (unsigned)bfd_getl32 (buf
+ 28),
5849 (unsigned)bfd_getl32 (buf
+ 24));
5851 fprintf (file
, _(" psect idx 3: %u, offset 3: 0x%08x %08x\n"),
5852 (unsigned)bfd_getl32 (buf
+ 32),
5853 (unsigned)bfd_getl32 (buf
+ 40),
5854 (unsigned)bfd_getl32 (buf
+ 36));
5856 fprintf (file
, _(" global name: %.*s\n"), buf
[32], buf
+ 33);
5860 evax_bfd_print_etir (FILE *file
, const char *name
,
5861 unsigned char *rec
, unsigned int rec_len
)
5863 unsigned int off
= sizeof (struct vms_egsd
);
5864 unsigned int sec_len
;
5866 fprintf (file
, _(" %s (len=%u+%u):\n"), name
,
5867 (unsigned)(rec_len
- sizeof (struct vms_eobjrec
)),
5868 (unsigned)sizeof (struct vms_eobjrec
));
5870 for (off
= sizeof (struct vms_eobjrec
); off
< rec_len
; )
5872 struct vms_etir
*etir
= (struct vms_etir
*)(rec
+ off
);
5877 type
= bfd_getl16 (etir
->rectyp
);
5878 size
= bfd_getl16 (etir
->size
);
5879 buf
= rec
+ off
+ sizeof (struct vms_etir
);
5881 fprintf (file
, _(" (type: %3u, size: 4+%3u): "), type
, size
- 4);
5884 case ETIR__C_STA_GBL
:
5885 fprintf (file
, _("STA_GBL (stack global) %.*s\n"),
5888 case ETIR__C_STA_LW
:
5889 fprintf (file
, _("STA_LW (stack longword) 0x%08x\n"),
5890 (unsigned)bfd_getl32 (buf
));
5892 case ETIR__C_STA_QW
:
5893 fprintf (file
, _("STA_QW (stack quadword) 0x%08x %08x\n"),
5894 (unsigned)bfd_getl32 (buf
+ 4),
5895 (unsigned)bfd_getl32 (buf
+ 0));
5897 case ETIR__C_STA_PQ
:
5898 fprintf (file
, _("STA_PQ (stack psect base + offset)\n"));
5899 fprintf (file
, _(" psect: %u, offset: 0x%08x %08x\n"),
5900 (unsigned)bfd_getl32 (buf
+ 0),
5901 (unsigned)bfd_getl32 (buf
+ 8),
5902 (unsigned)bfd_getl32 (buf
+ 4));
5904 case ETIR__C_STA_LI
:
5905 fprintf (file
, _("STA_LI (stack literal)\n"));
5907 case ETIR__C_STA_MOD
:
5908 fprintf (file
, _("STA_MOD (stack module)\n"));
5910 case ETIR__C_STA_CKARG
:
5911 fprintf (file
, _("STA_CKARG (compare procedure argument)\n"));
5915 fprintf (file
, _("STO_B (store byte)\n"));
5918 fprintf (file
, _("STO_W (store word)\n"));
5920 case ETIR__C_STO_LW
:
5921 fprintf (file
, _("STO_LW (store longword)\n"));
5923 case ETIR__C_STO_QW
:
5924 fprintf (file
, _("STO_QW (store quadword)\n"));
5926 case ETIR__C_STO_IMMR
:
5928 unsigned int len
= bfd_getl32 (buf
);
5930 _("STO_IMMR (store immediate repeat) %u bytes\n"),
5932 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
5936 case ETIR__C_STO_GBL
:
5937 fprintf (file
, _("STO_GBL (store global) %.*s\n"),
5940 case ETIR__C_STO_CA
:
5941 fprintf (file
, _("STO_CA (store code address) %.*s\n"),
5944 case ETIR__C_STO_RB
:
5945 fprintf (file
, _("STO_RB (store relative branch)\n"));
5947 case ETIR__C_STO_AB
:
5948 fprintf (file
, _("STO_AB (store absolute branch)\n"));
5950 case ETIR__C_STO_OFF
:
5951 fprintf (file
, _("STO_OFF (store offset to psect)\n"));
5953 case ETIR__C_STO_IMM
:
5955 unsigned int len
= bfd_getl32 (buf
);
5957 _("STO_IMM (store immediate) %u bytes\n"),
5959 evax_bfd_print_hex (file
, " ", buf
+ 4, len
);
5963 case ETIR__C_STO_LP_PSB
:
5964 fprintf (file
, _("STO_OFF (store LP with procedure signature)\n"));
5966 case ETIR__C_STO_HINT_GBL
:
5967 fprintf (file
, _("STO_BR_GBL (store branch global) *todo*\n"));
5969 case ETIR__C_STO_HINT_PS
:
5970 fprintf (file
, _("STO_BR_PS (store branch psect + offset) *todo*\n"));
5973 case ETIR__C_OPR_NOP
:
5974 fprintf (file
, _("OPR_NOP (no-operation)\n"));
5976 case ETIR__C_OPR_ADD
:
5977 fprintf (file
, _("OPR_ADD (add)\n"));
5979 case ETIR__C_OPR_SUB
:
5980 fprintf (file
, _("OPR_SUB (substract)\n"));
5982 case ETIR__C_OPR_MUL
:
5983 fprintf (file
, _("OPR_MUL (multiply)\n"));
5985 case ETIR__C_OPR_DIV
:
5986 fprintf (file
, _("OPR_DIV (divide)\n"));
5988 case ETIR__C_OPR_AND
:
5989 fprintf (file
, _("OPR_AND (logical and)\n"));
5991 case ETIR__C_OPR_IOR
:
5992 fprintf (file
, _("OPR_IOR (logical inclusive or)\n"));
5994 case ETIR__C_OPR_EOR
:
5995 fprintf (file
, _("OPR_EOR (logical exclusive or)\n"));
5997 case ETIR__C_OPR_NEG
:
5998 fprintf (file
, _("OPR_NEG (negate)\n"));
6000 case ETIR__C_OPR_COM
:
6001 fprintf (file
, _("OPR_COM (complement)\n"));
6003 case ETIR__C_OPR_INSV
:
6004 fprintf (file
, _("OPR_INSV (insert field)\n"));
6006 case ETIR__C_OPR_ASH
:
6007 fprintf (file
, _("OPR_ASH (arithmetic shift)\n"));
6009 case ETIR__C_OPR_USH
:
6010 fprintf (file
, _("OPR_USH (unsigned shift)\n"));
6012 case ETIR__C_OPR_ROT
:
6013 fprintf (file
, _("OPR_ROT (rotate)\n"));
6015 case ETIR__C_OPR_SEL
:
6016 fprintf (file
, _("OPR_SEL (select)\n"));
6018 case ETIR__C_OPR_REDEF
:
6019 fprintf (file
, _("OPR_REDEF (redefine symbol to curr location)\n"));
6021 case ETIR__C_OPR_DFLIT
:
6022 fprintf (file
, _("OPR_REDEF (define a literal)\n"));
6025 case ETIR__C_STC_LP
:
6026 fprintf (file
, _("STC_LP (store cond linkage pair)\n"));
6028 case ETIR__C_STC_LP_PSB
:
6030 _("STC_LP_PSB (store cond linkage pair + signature)\n"));
6031 fprintf (file
, _(" linkage index: %u, procedure: %.*s\n"),
6032 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6033 buf
+= 4 + 1 + buf
[4];
6034 fprintf (file
, _(" signature: %.*s\n"), buf
[0], buf
+ 1);
6036 case ETIR__C_STC_GBL
:
6037 fprintf (file
, _("STC_GBL (store cond global)\n"));
6038 fprintf (file
, _(" linkage index: %u, global: %.*s\n"),
6039 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6041 case ETIR__C_STC_GCA
:
6042 fprintf (file
, _("STC_GCA (store cond code address)\n"));
6043 fprintf (file
, _(" linkage index: %u, procedure name: %.*s\n"),
6044 (unsigned)bfd_getl32 (buf
), buf
[4], buf
+ 5);
6046 case ETIR__C_STC_PS
:
6047 fprintf (file
, _("STC_PS (store cond psect + offset)\n"));
6049 _(" linkage index: %u, psect: %u, offset: 0x%08x %08x\n"),
6050 (unsigned)bfd_getl32 (buf
),
6051 (unsigned)bfd_getl32 (buf
+ 4),
6052 (unsigned)bfd_getl32 (buf
+ 12),
6053 (unsigned)bfd_getl32 (buf
+ 8));
6055 case ETIR__C_STC_NOP_GBL
:
6056 fprintf (file
, _("STC_NOP_GBL (store cond NOP at global addr)\n"));
6057 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6059 case ETIR__C_STC_NOP_PS
:
6060 fprintf (file
, _("STC_NOP_PS (store cond NOP at psect + offset)\n"));
6061 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6063 case ETIR__C_STC_BSR_GBL
:
6064 fprintf (file
, _("STC_BSR_GBL (store cond BSR at global addr)\n"));
6065 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6067 case ETIR__C_STC_BSR_PS
:
6068 fprintf (file
, _("STC_BSR_PS (store cond BSR at psect + offset)\n"));
6069 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6071 case ETIR__C_STC_LDA_GBL
:
6072 fprintf (file
, _("STC_LDA_GBL (store cond LDA at global addr)\n"));
6073 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6075 case ETIR__C_STC_LDA_PS
:
6076 fprintf (file
, _("STC_LDA_PS (store cond LDA at psect + offset)\n"));
6077 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6079 case ETIR__C_STC_BOH_GBL
:
6080 fprintf (file
, _("STC_BOH_GBL (store cond BOH at global addr)\n"));
6081 evax_bfd_print_etir_stc_ir (file
, buf
, 0);
6083 case ETIR__C_STC_BOH_PS
:
6084 fprintf (file
, _("STC_BOH_PS (store cond BOH at psect + offset)\n"));
6085 evax_bfd_print_etir_stc_ir (file
, buf
, 1);
6087 case ETIR__C_STC_NBH_GBL
:
6089 _("STC_NBH_GBL (store cond or hint at global addr)\n"));
6091 case ETIR__C_STC_NBH_PS
:
6093 _("STC_NBH_PS (store cond or hint at psect + offset)\n"));
6096 case ETIR__C_CTL_SETRB
:
6097 fprintf (file
, _("CTL_SETRB (set relocation base)\n"));
6100 case ETIR__C_CTL_AUGRB
:
6102 unsigned int val
= bfd_getl32 (buf
);
6103 fprintf (file
, _("CTL_AUGRB (augment relocation base) %u\n"), val
);
6106 case ETIR__C_CTL_DFLOC
:
6107 fprintf (file
, _("CTL_DFLOC (define location)\n"));
6109 case ETIR__C_CTL_STLOC
:
6110 fprintf (file
, _("CTL_STLOC (set location)\n"));
6112 case ETIR__C_CTL_STKDL
:
6113 fprintf (file
, _("CTL_STKDL (stack defined location)\n"));
6116 fprintf (file
, _("*unhandled*\n"));
6124 evax_bfd_print_eobj (struct bfd
*abfd
, FILE *file
)
6126 bfd_boolean is_first
= TRUE
;
6127 bfd_boolean has_records
= FALSE
;
6131 unsigned int rec_len
;
6132 unsigned int pad_len
;
6134 unsigned int hdr_size
;
6139 unsigned char buf
[6];
6144 if (bfd_bread (buf
, sizeof (buf
), abfd
) != sizeof (buf
))
6146 fprintf (file
, _("cannot read GST record length\n"));
6149 rec_len
= bfd_getl16 (buf
+ 0);
6150 if (rec_len
== bfd_getl16 (buf
+ 4)
6151 && bfd_getl16 (buf
+ 2) == EOBJ__C_EMH
)
6153 /* The format is raw: record-size, type, record-size. */
6155 pad_len
= (rec_len
+ 1) & ~1U;
6158 else if (rec_len
== EOBJ__C_EMH
)
6160 has_records
= FALSE
;
6161 pad_len
= bfd_getl16 (buf
+ 2);
6167 fprintf (file
, _("cannot find EMH in first GST record\n"));
6170 rec
= bfd_malloc (pad_len
);
6171 memcpy (rec
, buf
+ sizeof (buf
) - hdr_size
, hdr_size
);
6175 unsigned int rec_len2
= 0;
6176 unsigned char hdr
[4];
6180 unsigned char buf_len
[2];
6182 if (bfd_bread (buf_len
, sizeof (buf_len
), abfd
)
6183 != sizeof (buf_len
))
6185 fprintf (file
, _("cannot read GST record length\n"));
6188 rec_len2
= (unsigned)bfd_getl16 (buf_len
);
6191 if (bfd_bread (hdr
, sizeof (hdr
), abfd
) != sizeof (hdr
))
6193 fprintf (file
, _("cannot read GST record header\n"));
6196 rec_len
= (unsigned)bfd_getl16 (hdr
+ 2);
6198 pad_len
= (rec_len
+ 1) & ~1U;
6201 rec
= bfd_malloc (pad_len
);
6202 memcpy (rec
, hdr
, sizeof (hdr
));
6203 hdr_size
= sizeof (hdr
);
6204 if (has_records
&& rec_len2
!= rec_len
)
6206 fprintf (file
, _(" corrupted GST\n"));
6211 if (bfd_bread (rec
+ hdr_size
, pad_len
- hdr_size
, abfd
)
6212 != pad_len
- hdr_size
)
6214 fprintf (file
, _("cannot read GST record\n"));
6218 type
= (unsigned)bfd_getl16 (rec
);
6223 evax_bfd_print_emh (file
, rec
, rec_len
);
6226 evax_bfd_print_egsd (file
, rec
, rec_len
);
6229 evax_bfd_print_eeom (file
, rec
, rec_len
);
6234 evax_bfd_print_etir (file
, "ETIR", rec
, rec_len
);
6237 evax_bfd_print_etir (file
, "EDBG", rec
, rec_len
);
6240 evax_bfd_print_etir (file
, "ETBT", rec
, rec_len
);
6243 fprintf (file
, _(" unhandled EOBJ record type %u\n"), type
);
6251 evax_bfd_print_relocation_records (FILE *file
, const unsigned char *rel
,
6252 unsigned int stride
)
6260 count
= bfd_getl32 (rel
+ 0);
6264 base
= bfd_getl32 (rel
+ 4);
6266 fprintf (file
, _(" bitcount: %u, base addr: 0x%08x\n"),
6270 for (j
= 0; count
> 0; j
+= 4, count
-= 32)
6276 val
= bfd_getl32 (rel
);
6279 fprintf (file
, _(" bitmap: 0x%08x (count: %u):\n"), val
, count
);
6281 for (k
= 0; k
< 32; k
++)
6286 fprintf (file
, _(" %08x"), base
+ (j
* 8 + k
) * stride
);
6301 evax_bfd_print_address_fixups (FILE *file
, const unsigned char *rel
)
6308 count
= bfd_getl32 (rel
+ 0);
6311 fprintf (file
, _(" image %u (%u entries)\n"),
6312 (unsigned)bfd_getl32 (rel
+ 4), count
);
6314 for (j
= 0; j
< count
; j
++)
6316 fprintf (file
, _(" offset: 0x%08x, val: 0x%08x\n"),
6317 (unsigned)bfd_getl32 (rel
+ 0),
6318 (unsigned)bfd_getl32 (rel
+ 4));
6325 evax_bfd_print_reference_fixups (FILE *file
, const unsigned char *rel
)
6334 count
= bfd_getl32 (rel
+ 0);
6337 fprintf (file
, _(" image %u (%u entries), offsets:\n"),
6338 (unsigned)bfd_getl32 (rel
+ 4), count
);
6340 for (j
= 0; j
< count
; j
++)
6344 fprintf (file
, _(" 0x%08x"), (unsigned)bfd_getl32 (rel
));
6359 evax_bfd_print_indent (int indent
, FILE *file
)
6361 for (; indent
; indent
--)
6366 evax_bfd_get_dsc_name (unsigned int v
)
6370 case DSC__K_DTYPE_Z
:
6371 return "Z (Unspecified)";
6372 case DSC__K_DTYPE_V
:
6374 case DSC__K_DTYPE_BU
:
6375 return "BU (Byte logical)";
6376 case DSC__K_DTYPE_WU
:
6377 return "WU (Word logical)";
6378 case DSC__K_DTYPE_LU
:
6379 return "LU (Longword logical)";
6380 case DSC__K_DTYPE_QU
:
6381 return "QU (Quadword logical)";
6382 case DSC__K_DTYPE_B
:
6383 return "B (Byte integer)";
6384 case DSC__K_DTYPE_W
:
6385 return "W (Word integer)";
6386 case DSC__K_DTYPE_L
:
6387 return "L (Longword integer)";
6388 case DSC__K_DTYPE_Q
:
6389 return "Q (Quadword integer)";
6390 case DSC__K_DTYPE_F
:
6391 return "F (Single-precision floating)";
6392 case DSC__K_DTYPE_D
:
6393 return "D (Double-precision floating)";
6394 case DSC__K_DTYPE_FC
:
6395 return "FC (Complex)";
6396 case DSC__K_DTYPE_DC
:
6397 return "DC (Double-precision Complex)";
6398 case DSC__K_DTYPE_T
:
6399 return "T (ASCII text string)";
6400 case DSC__K_DTYPE_NU
:
6401 return "NU (Numeric string, unsigned)";
6402 case DSC__K_DTYPE_NL
:
6403 return "NL (Numeric string, left separate sign)";
6404 case DSC__K_DTYPE_NLO
:
6405 return "NLO (Numeric string, left overpunched sign)";
6406 case DSC__K_DTYPE_NR
:
6407 return "NR (Numeric string, right separate sign)";
6408 case DSC__K_DTYPE_NRO
:
6409 return "NRO (Numeric string, right overpunched sig)";
6410 case DSC__K_DTYPE_NZ
:
6411 return "NZ (Numeric string, zoned sign)";
6412 case DSC__K_DTYPE_P
:
6413 return "P (Packed decimal string)";
6414 case DSC__K_DTYPE_ZI
:
6415 return "ZI (Sequence of instructions)";
6416 case DSC__K_DTYPE_ZEM
:
6417 return "ZEM (Procedure entry mask)";
6418 case DSC__K_DTYPE_DSC
:
6419 return "DSC (Descriptor, used for arrays of dyn strings)";
6420 case DSC__K_DTYPE_OU
:
6421 return "OU (Octaword logical)";
6422 case DSC__K_DTYPE_O
:
6423 return "O (Octaword integer)";
6424 case DSC__K_DTYPE_G
:
6425 return "G (Double precision G floating, 64 bit)";
6426 case DSC__K_DTYPE_H
:
6427 return "H (Quadruple precision floating, 128 bit)";
6428 case DSC__K_DTYPE_GC
:
6429 return "GC (Double precision complex, G floating)";
6430 case DSC__K_DTYPE_HC
:
6431 return "HC (Quadruple precision complex, H floating)";
6432 case DSC__K_DTYPE_CIT
:
6433 return "CIT (COBOL intermediate temporary)";
6434 case DSC__K_DTYPE_BPV
:
6435 return "BPV (Bound Procedure Value)";
6436 case DSC__K_DTYPE_BLV
:
6437 return "BLV (Bound Label Value)";
6438 case DSC__K_DTYPE_VU
:
6439 return "VU (Bit Unaligned)";
6440 case DSC__K_DTYPE_ADT
:
6441 return "ADT (Absolute Date-Time)";
6442 case DSC__K_DTYPE_VT
:
6443 return "VT (Varying Text)";
6444 case DSC__K_DTYPE_T2
:
6445 return "T2 (16-bit char)";
6446 case DSC__K_DTYPE_VT2
:
6447 return "VT2 (16-bit varying char)";
6449 return "?? (unknown)";
6454 evax_bfd_print_desc (const unsigned char *buf
, int indent
, FILE *file
)
6456 unsigned char bclass
= buf
[3];
6457 unsigned char dtype
= buf
[2];
6458 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6459 unsigned int pointer
= (unsigned)bfd_getl32 (buf
+ 4);
6461 evax_bfd_print_indent (indent
, file
);
6463 if (len
== 1 && pointer
== 0xffffffffUL
)
6466 fprintf (file
, _("64 bits *unhandled*\n"));
6470 fprintf (file
, _("class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"),
6471 bclass
, dtype
, len
, pointer
);
6474 case DSC__K_CLASS_NCA
:
6476 const struct vms_dsc_nca
*dsc
= (const void *)buf
;
6478 const unsigned char *b
;
6480 evax_bfd_print_indent (indent
, file
);
6481 fprintf (file
, _("non-contiguous array of %s\n"),
6482 evax_bfd_get_dsc_name (dsc
->dtype
));
6483 evax_bfd_print_indent (indent
+ 1, file
);
6485 _("dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"),
6486 dsc
->dimct
, dsc
->aflags
, dsc
->digits
, dsc
->scale
);
6487 evax_bfd_print_indent (indent
+ 1, file
);
6489 _("arsize: %u, a0: 0x%08x\n"),
6490 (unsigned)bfd_getl32 (dsc
->arsize
),
6491 (unsigned)bfd_getl32 (dsc
->a0
));
6492 evax_bfd_print_indent (indent
+ 1, file
);
6493 fprintf (file
, _("Strides:\n"));
6494 b
= buf
+ sizeof (*dsc
);
6495 for (i
= 0; i
< dsc
->dimct
; i
++)
6497 evax_bfd_print_indent (indent
+ 2, file
);
6498 fprintf (file
, _("[%u]: %u\n"), i
+ 1,
6499 (unsigned)bfd_getl32 (b
));
6502 evax_bfd_print_indent (indent
+ 1, file
);
6503 fprintf (file
, _("Bounds:\n"));
6504 b
= buf
+ sizeof (*dsc
);
6505 for (i
= 0; i
< dsc
->dimct
; i
++)
6507 evax_bfd_print_indent (indent
+ 2, file
);
6508 fprintf (file
, _("[%u]: Lower: %u, upper: %u\n"), i
+ 1,
6509 (unsigned)bfd_getl32 (b
+ 0),
6510 (unsigned)bfd_getl32 (b
+ 4));
6515 case DSC__K_CLASS_UBS
:
6517 const struct vms_dsc_ubs
*ubs
= (const void *)buf
;
6519 evax_bfd_print_indent (indent
, file
);
6520 fprintf (file
, _("unaligned bit-string of %s\n"),
6521 evax_bfd_get_dsc_name (ubs
->dtype
));
6522 evax_bfd_print_indent (indent
+ 1, file
);
6524 _("base: %u, pos: %u\n"),
6525 (unsigned)bfd_getl32 (ubs
->base
),
6526 (unsigned)bfd_getl32 (ubs
->pos
));
6530 fprintf (file
, _("*unhandled*\n"));
6537 evax_bfd_print_valspec (const unsigned char *buf
, int indent
, FILE *file
)
6539 unsigned int vflags
= buf
[0];
6540 unsigned int value
= (unsigned)bfd_getl32 (buf
+ 1);
6541 unsigned int len
= 5;
6543 evax_bfd_print_indent (indent
, file
);
6544 fprintf (file
, _("vflags: 0x%02x, value: 0x%08x "), vflags
, value
);
6549 case DST__K_VFLAGS_NOVAL
:
6550 fprintf (file
, _("(no value)\n"));
6552 case DST__K_VFLAGS_NOTACTIVE
:
6553 fprintf (file
, _("(not active)\n"));
6555 case DST__K_VFLAGS_UNALLOC
:
6556 fprintf (file
, _("(not allocated)\n"));
6558 case DST__K_VFLAGS_DSC
:
6559 fprintf (file
, _("(descriptor)\n"));
6560 evax_bfd_print_desc (buf
+ value
, indent
+ 1, file
);
6562 case DST__K_VFLAGS_TVS
:
6563 fprintf (file
, _("(trailing value)\n"));
6565 case DST__K_VS_FOLLOWS
:
6566 fprintf (file
, _("(value spec follows)\n"));
6568 case DST__K_VFLAGS_BITOFFS
:
6569 fprintf (file
, _("(at bit offset %u)\n"), value
);
6572 fprintf (file
, _("(reg: %u, disp: %u, indir: %u, kind: "),
6573 (vflags
& DST__K_REGNUM_MASK
) >> DST__K_REGNUM_SHIFT
,
6574 vflags
& DST__K_DISP
? 1 : 0,
6575 vflags
& DST__K_INDIR
? 1 : 0);
6576 switch (vflags
& DST__K_VALKIND_MASK
)
6578 case DST__K_VALKIND_LITERAL
:
6579 fputs (_("literal"), file
);
6581 case DST__K_VALKIND_ADDR
:
6582 fputs (_("address"), file
);
6584 case DST__K_VALKIND_DESC
:
6585 fputs (_("desc"), file
);
6587 case DST__K_VALKIND_REG
:
6588 fputs (_("reg"), file
);
6591 fputs (")\n", file
);
6598 evax_bfd_print_typspec (const unsigned char *buf
, int indent
, FILE *file
)
6600 unsigned char kind
= buf
[2];
6601 unsigned int len
= (unsigned)bfd_getl16 (buf
);
6603 evax_bfd_print_indent (indent
, file
);
6604 fprintf (file
, ("len: %2u, kind: %2u "), len
, kind
);
6608 case DST__K_TS_ATOM
:
6609 fprintf (file
, ("atomic, type=0x%02x %s\n"),
6610 buf
[0], evax_bfd_get_dsc_name (buf
[0]));
6613 fprintf (file
, ("indirect, defined at 0x%08x\n"),
6614 (unsigned)bfd_getl32 (buf
));
6616 case DST__K_TS_TPTR
:
6617 fprintf (file
, ("typed pointer\n"));
6618 evax_bfd_print_typspec (buf
, indent
+ 1, file
);
6621 fprintf (file
, ("pointer\n"));
6623 case DST__K_TS_ARRAY
:
6625 const unsigned char *vs
;
6626 unsigned int vec_len
;
6629 fprintf (file
, ("array, dim: %u, bitmap: "), buf
[0]);
6630 vec_len
= (buf
[0] + 1 + 7) / 8;
6631 for (i
= 0; i
< vec_len
; i
++)
6632 fprintf (file
, " %02x", buf
[i
+ 1]);
6634 vs
= buf
+ 1 + vec_len
;
6635 evax_bfd_print_indent (indent
, file
);
6636 fprintf (file
, ("array descriptor:\n"));
6637 vs
+= evax_bfd_print_valspec (vs
, indent
+ 1, file
);
6638 for (i
= 0; i
< buf
[0] + 1U; i
++)
6639 if (buf
[1 + i
/ 8] & (1 << (i
% 8)))
6641 evax_bfd_print_indent (indent
, file
);
6643 fprintf (file
, ("type spec for element:\n"));
6645 fprintf (file
, ("type spec for subscript %u:\n"), i
);
6646 evax_bfd_print_typspec (vs
, indent
+ 1, file
);
6647 vs
+= bfd_getl16 (vs
);
6652 fprintf (file
, ("*unhandled*\n"));
6657 evax_bfd_print_dst (struct bfd
*abfd
, unsigned int dst_size
, FILE *file
)
6659 unsigned int off
= 0;
6660 unsigned int pc
= 0;
6661 unsigned int line
= 0;
6663 fprintf (file
, _("Debug symbol table:\n"));
6665 while (dst_size
> 0)
6667 struct vms_dst_header dsth
;
6672 if (bfd_bread (&dsth
, sizeof (dsth
), abfd
) != sizeof (dsth
))
6674 fprintf (file
, _("cannot read DST header\n"));
6677 len
= bfd_getl16 (dsth
.length
);
6678 type
= bfd_getl16 (dsth
.type
);
6679 fprintf (file
, _(" type: %3u, len: %3u (at 0x%08x): "),
6689 len
-= sizeof (dsth
);
6690 buf
= bfd_malloc (len
);
6691 if (bfd_bread (buf
, len
, abfd
) != len
)
6693 fprintf (file
, _("cannot read DST symbol\n"));
6698 case DSC__K_DTYPE_V
:
6699 case DSC__K_DTYPE_BU
:
6700 case DSC__K_DTYPE_WU
:
6701 case DSC__K_DTYPE_LU
:
6702 case DSC__K_DTYPE_QU
:
6703 case DSC__K_DTYPE_B
:
6704 case DSC__K_DTYPE_W
:
6705 case DSC__K_DTYPE_L
:
6706 case DSC__K_DTYPE_Q
:
6707 case DSC__K_DTYPE_F
:
6708 case DSC__K_DTYPE_D
:
6709 case DSC__K_DTYPE_FC
:
6710 case DSC__K_DTYPE_DC
:
6711 case DSC__K_DTYPE_T
:
6712 case DSC__K_DTYPE_NU
:
6713 case DSC__K_DTYPE_NL
:
6714 case DSC__K_DTYPE_NLO
:
6715 case DSC__K_DTYPE_NR
:
6716 case DSC__K_DTYPE_NRO
:
6717 case DSC__K_DTYPE_NZ
:
6718 case DSC__K_DTYPE_P
:
6719 case DSC__K_DTYPE_ZI
:
6720 case DSC__K_DTYPE_ZEM
:
6721 case DSC__K_DTYPE_DSC
:
6722 case DSC__K_DTYPE_OU
:
6723 case DSC__K_DTYPE_O
:
6724 case DSC__K_DTYPE_G
:
6725 case DSC__K_DTYPE_H
:
6726 case DSC__K_DTYPE_GC
:
6727 case DSC__K_DTYPE_HC
:
6728 case DSC__K_DTYPE_CIT
:
6729 case DSC__K_DTYPE_BPV
:
6730 case DSC__K_DTYPE_BLV
:
6731 case DSC__K_DTYPE_VU
:
6732 case DSC__K_DTYPE_ADT
:
6733 case DSC__K_DTYPE_VT
:
6734 case DSC__K_DTYPE_T2
:
6735 case DSC__K_DTYPE_VT2
:
6736 fprintf (file
, _("standard data: %s\n"),
6737 evax_bfd_get_dsc_name (type
));
6738 evax_bfd_print_valspec (buf
, 4, file
);
6739 fprintf (file
, _(" name: %.*s\n"), buf
[5], buf
+ 6);
6743 struct vms_dst_modbeg
*dst
= (void *)buf
;
6744 const char *name
= (const char *)buf
+ sizeof (*dst
);
6746 fprintf (file
, _("modbeg\n"));
6747 fprintf (file
, _(" flags: %d, language: %u, "
6748 "major: %u, minor: %u\n"),
6750 (unsigned)bfd_getl32 (dst
->language
),
6751 (unsigned)bfd_getl16 (dst
->major
),
6752 (unsigned)bfd_getl16 (dst
->minor
));
6753 fprintf (file
, _(" module name: %.*s\n"),
6755 name
+= name
[0] + 1;
6756 fprintf (file
, _(" compiler : %.*s\n"),
6761 fprintf (file
, _("modend\n"));
6765 struct vms_dst_rtnbeg
*dst
= (void *)buf
;
6766 const char *name
= (const char *)buf
+ sizeof (*dst
);
6768 fputs (_("rtnbeg\n"), file
);
6769 fprintf (file
, _(" flags: %u, address: 0x%08x, "
6770 "pd-address: 0x%08x\n"),
6772 (unsigned)bfd_getl32 (dst
->address
),
6773 (unsigned)bfd_getl32 (dst
->pd_address
));
6774 fprintf (file
, _(" routine name: %.*s\n"),
6780 struct vms_dst_rtnend
*dst
= (void *)buf
;
6782 fprintf (file
, _("rtnend: size 0x%08x\n"),
6783 (unsigned)bfd_getl32 (dst
->size
));
6788 struct vms_dst_prolog
*dst
= (void *)buf
;
6790 fprintf (file
, _("prolog: bkpt address 0x%08x\n"),
6791 (unsigned)bfd_getl32 (dst
->bkpt_addr
));
6796 struct vms_dst_epilog
*dst
= (void *)buf
;
6798 fprintf (file
, _("epilog: flags: %u, count: %u\n"),
6799 dst
->flags
, (unsigned)bfd_getl32 (dst
->count
));
6804 struct vms_dst_blkbeg
*dst
= (void *)buf
;
6805 const char *name
= (const char *)buf
+ sizeof (*dst
);
6807 fprintf (file
, _("blkbeg: address: 0x%08x, name: %.*s\n"),
6808 (unsigned)bfd_getl32 (dst
->address
),
6814 struct vms_dst_blkend
*dst
= (void *)buf
;
6816 fprintf (file
, _("blkend: size: 0x%08x\n"),
6817 (unsigned)bfd_getl32 (dst
->size
));
6820 case DST__K_TYPSPEC
:
6822 fprintf (file
, _("typspec (len: %u)\n"), len
);
6823 fprintf (file
, _(" name: %.*s\n"), buf
[0], buf
+ 1);
6824 evax_bfd_print_typspec (buf
+ 1 + buf
[0], 5, file
);
6829 fprintf (file
, _("septyp, name: %.*s\n"), buf
[5], buf
+ 6);
6830 evax_bfd_print_valspec (buf
, 4, file
);
6835 struct vms_dst_recbeg
*recbeg
= (void *)buf
;
6836 const char *name
= (const char *)buf
+ sizeof (*recbeg
);
6838 fprintf (file
, _("recbeg: name: %.*s\n"), name
[0], name
+ 1);
6839 evax_bfd_print_valspec (buf
, 4, file
);
6840 fprintf (file
, (" len: %u bits\n"),
6841 (unsigned)bfd_getl32 (name
+ 1 + name
[0]));
6845 fprintf (file
, _("recend\n"));
6847 case DST__K_ENUMBEG
:
6848 fprintf (file
, _("enumbeg, len: %u, name: %.*s\n"),
6849 buf
[0], buf
[1], buf
+ 2);
6851 case DST__K_ENUMELT
:
6852 fprintf (file
, _("enumelt, name: %.*s\n"), buf
[5], buf
+ 6);
6853 evax_bfd_print_valspec (buf
, 4, file
);
6855 case DST__K_ENUMEND
:
6856 fprintf (file
, _("enumend\n"));
6860 struct vms_dst_label
*lab
= (void *)buf
;
6861 fprintf (file
, ("label, name: %.*s\n"),
6862 lab
->name
[0], lab
->name
+ 1);
6863 fprintf (file
, (" address: 0x%08x\n"),
6864 (unsigned)bfd_getl32 (lab
->value
));
6867 case DST__K_DIS_RANGE
:
6869 unsigned int cnt
= bfd_getl32 (buf
);
6870 unsigned char *rng
= buf
+ 4;
6873 fprintf (file
, _("discontiguous range (nbr: %u)\n"), cnt
);
6874 for (i
= 0; i
< cnt
; i
++, rng
+= 8)
6875 fprintf (file
, _(" address: 0x%08x, size: %u\n"),
6876 (unsigned)bfd_getl32 (rng
),
6877 (unsigned)bfd_getl32 (rng
+ 4));
6881 case DST__K_LINE_NUM
:
6883 unsigned char *buf_orig
= buf
;
6885 fprintf (file
, _("line num (len: %u)\n"), len
);
6890 unsigned char cmdlen
;
6900 case DST__K_DELTA_PC_W
:
6901 val
= bfd_getl16 (buf
+ 1);
6902 fprintf (file
, _("delta_pc_w %u\n"), val
);
6907 case DST__K_INCR_LINUM
:
6909 fprintf (file
, _("incr_linum: +%u\n"), val
);
6913 case DST__K_INCR_LINUM_W
:
6914 val
= bfd_getl16 (buf
+ 1);
6915 fprintf (file
, _("incr_linum: +%u\n"), val
);
6919 case DST__K_SET_LINUM
:
6920 line
= (unsigned)bfd_getl16 (buf
+ 1);
6921 fprintf (file
, _("set_line_num %u\n"), line
);
6924 case DST__K_SET_LINUM_B
:
6926 fprintf (file
, _("set_line_num_b %u\n"), line
);
6929 case DST__K_SET_LINUM_L
:
6930 line
= (unsigned)bfd_getl32 (buf
+ 1);
6931 fprintf (file
, _("set_line_num_l %u\n"), line
);
6934 case DST__K_SET_ABS_PC
:
6935 pc
= (unsigned)bfd_getl32 (buf
+ 1);
6936 fprintf (file
, _("set_abs_pc: 0x%08x\n"), pc
);
6939 case DST__K_DELTA_PC_L
:
6940 fprintf (file
, _("delta_pc_l: +0x%08x\n"),
6941 (unsigned)bfd_getl32 (buf
+ 1));
6945 fprintf (file
, _("term: 0x%02x"), buf
[1]);
6947 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
6951 val
= bfd_getl16 (buf
+ 1);
6952 fprintf (file
, _("term_w: 0x%04x"), val
);
6954 fprintf (file
, _(" pc: 0x%08x\n"), pc
);
6960 fprintf (file
, _("delta pc +%-4d"), -cmd
);
6961 line
++; /* FIXME: curr increment. */
6963 fprintf (file
, _(" pc: 0x%08x line: %5u\n"),
6968 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
6981 unsigned char *buf_orig
= buf
;
6983 fprintf (file
, _("source (len: %u)\n"), len
);
6987 signed char cmd
= buf
[0];
6988 unsigned char cmdlen
= 0;
6992 case DST__K_SRC_DECLFILE
:
6994 struct vms_dst_src_decl_src
*src
= (void *)(buf
+ 1);
6997 fprintf (file
, _(" declfile: len: %u, flags: %u, "
6999 src
->length
, src
->flags
,
7000 (unsigned)bfd_getl16 (src
->fileid
));
7001 fprintf (file
, _(" rms: cdt: 0x%08x %08x, "
7002 "ebk: 0x%08x, ffb: 0x%04x, "
7004 (unsigned)bfd_getl32 (src
->rms_cdt
+ 4),
7005 (unsigned)bfd_getl32 (src
->rms_cdt
+ 0),
7006 (unsigned)bfd_getl32 (src
->rms_ebk
),
7007 (unsigned)bfd_getl16 (src
->rms_ffb
),
7009 name
= (const char *)buf
+ 1 + sizeof (*src
);
7010 fprintf (file
, _(" filename : %.*s\n"),
7012 name
+= name
[0] + 1;
7013 fprintf (file
, _(" module name: %.*s\n"),
7015 cmdlen
= 2 + src
->length
;
7018 case DST__K_SRC_SETFILE
:
7019 fprintf (file
, _(" setfile %u\n"),
7020 (unsigned)bfd_getl16 (buf
+ 1));
7023 case DST__K_SRC_SETREC_W
:
7024 fprintf (file
, _(" setrec %u\n"),
7025 (unsigned)bfd_getl16 (buf
+ 1));
7028 case DST__K_SRC_SETREC_L
:
7029 fprintf (file
, _(" setrec %u\n"),
7030 (unsigned)bfd_getl32 (buf
+ 1));
7033 case DST__K_SRC_SETLNUM_W
:
7034 fprintf (file
, _(" setlnum %u\n"),
7035 (unsigned)bfd_getl16 (buf
+ 1));
7038 case DST__K_SRC_SETLNUM_L
:
7039 fprintf (file
, _(" setlnum %u\n"),
7040 (unsigned)bfd_getl32 (buf
+ 1));
7043 case DST__K_SRC_DEFLINES_W
:
7044 fprintf (file
, _(" deflines %u\n"),
7045 (unsigned)bfd_getl16 (buf
+ 1));
7048 case DST__K_SRC_DEFLINES_B
:
7049 fprintf (file
, _(" deflines %u\n"), buf
[1]);
7052 case DST__K_SRC_FORMFEED
:
7053 fprintf (file
, _(" formfeed\n"));
7057 fprintf (file
, _(" *unhandled* cmd %u\n"), cmd
);
7069 fprintf (file
, _("*unhandled* dst type %u\n"), type
);
7077 evax_bfd_print_image (bfd
*abfd
, FILE *file
)
7079 struct vms_eihd eihd
;
7082 unsigned int eiha_off
;
7083 unsigned int eihi_off
;
7084 unsigned int eihs_off
;
7085 unsigned int eisd_off
;
7086 unsigned int eihef_off
= 0;
7087 unsigned int eihnp_off
= 0;
7088 unsigned int dmt_vbn
= 0;
7089 unsigned int dmt_size
= 0;
7090 unsigned int dst_vbn
= 0;
7091 unsigned int dst_size
= 0;
7092 unsigned int gst_vbn
= 0;
7093 unsigned int gst_size
= 0;
7094 unsigned int eiaf_vbn
= 0;
7095 unsigned int eiaf_size
= 0;
7096 unsigned int eihvn_off
;
7098 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
)
7099 || bfd_bread (&eihd
, sizeof (eihd
), abfd
) != sizeof (eihd
))
7101 fprintf (file
, _("cannot read EIHD\n"));
7104 fprintf (file
, _("EIHD: (size: %u, nbr blocks: %u)\n"),
7105 (unsigned)bfd_getl32 (eihd
.size
),
7106 (unsigned)bfd_getl32 (eihd
.hdrblkcnt
));
7107 fprintf (file
, _(" majorid: %u, minorid: %u\n"),
7108 (unsigned)bfd_getl32 (eihd
.majorid
),
7109 (unsigned)bfd_getl32 (eihd
.minorid
));
7111 val
= (unsigned)bfd_getl32 (eihd
.imgtype
);
7115 name
= _("executable");
7118 name
= _("linkable image");
7121 name
= _("unknown");
7124 fprintf (file
, _(" image type: %u (%s)"), val
, name
);
7126 val
= (unsigned)bfd_getl32 (eihd
.subtype
);
7129 case EIHD__C_NATIVE
:
7136 name
= _("unknown");
7139 fprintf (file
, _(", subtype: %u (%s)\n"), val
, name
);
7141 eisd_off
= bfd_getl32 (eihd
.isdoff
);
7142 eiha_off
= bfd_getl32 (eihd
.activoff
);
7143 eihi_off
= bfd_getl32 (eihd
.imgidoff
);
7144 eihs_off
= bfd_getl32 (eihd
.symdbgoff
);
7145 fprintf (file
, _(" offsets: isd: %u, activ: %u, symdbg: %u, "
7146 "imgid: %u, patch: %u\n"),
7147 eisd_off
, eiha_off
, eihs_off
, eihi_off
,
7148 (unsigned)bfd_getl32 (eihd
.patchoff
));
7149 fprintf (file
, _(" fixup info rva: "));
7150 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.iafva
));
7151 fprintf (file
, _(", symbol vector rva: "));
7152 bfd_fprintf_vma (abfd
, file
, bfd_getl64 (eihd
.symvva
));
7153 eihvn_off
= bfd_getl32 (eihd
.version_array_off
);
7154 fprintf (file
, _("\n"
7155 " version array off: %u\n"),
7158 _(" img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"),
7159 (unsigned)bfd_getl32 (eihd
.imgiocnt
),
7160 (unsigned)bfd_getl32 (eihd
.iochancnt
),
7161 (unsigned)bfd_getl32 (eihd
.privreqs
+ 4),
7162 (unsigned)bfd_getl32 (eihd
.privreqs
+ 0));
7163 val
= (unsigned)bfd_getl32 (eihd
.lnkflags
);
7164 fprintf (file
, _(" linker flags: %08x:"), val
);
7165 if (val
& EIHD__M_LNKDEBUG
)
7166 fprintf (file
, " LNKDEBUG");
7167 if (val
& EIHD__M_LNKNOTFR
)
7168 fprintf (file
, " LNKNOTFR");
7169 if (val
& EIHD__M_NOP0BUFS
)
7170 fprintf (file
, " NOP0BUFS");
7171 if (val
& EIHD__M_PICIMG
)
7172 fprintf (file
, " PICIMG");
7173 if (val
& EIHD__M_P0IMAGE
)
7174 fprintf (file
, " P0IMAGE");
7175 if (val
& EIHD__M_DBGDMT
)
7176 fprintf (file
, " DBGDMT");
7177 if (val
& EIHD__M_INISHR
)
7178 fprintf (file
, " INISHR");
7179 if (val
& EIHD__M_XLATED
)
7180 fprintf (file
, " XLATED");
7181 if (val
& EIHD__M_BIND_CODE_SEC
)
7182 fprintf (file
, " BIND_CODE_SEC");
7183 if (val
& EIHD__M_BIND_DATA_SEC
)
7184 fprintf (file
, " BIND_DATA_SEC");
7185 if (val
& EIHD__M_MKTHREADS
)
7186 fprintf (file
, " MKTHREADS");
7187 if (val
& EIHD__M_UPCALLS
)
7188 fprintf (file
, " UPCALLS");
7189 if (val
& EIHD__M_OMV_READY
)
7190 fprintf (file
, " OMV_READY");
7191 if (val
& EIHD__M_EXT_BIND_SECT
)
7192 fprintf (file
, " EXT_BIND_SECT");
7193 fprintf (file
, "\n");
7194 fprintf (file
, _(" ident: 0x%08x, sysver: 0x%08x, "
7195 "match ctrl: %u, symvect_size: %u\n"),
7196 (unsigned)bfd_getl32 (eihd
.ident
),
7197 (unsigned)bfd_getl32 (eihd
.sysver
),
7199 (unsigned)bfd_getl32 (eihd
.symvect_size
));
7200 fprintf (file
, _(" BPAGE: %u"),
7201 (unsigned)bfd_getl32 (eihd
.virt_mem_block_size
));
7202 if (val
& (EIHD__M_OMV_READY
| EIHD__M_EXT_BIND_SECT
))
7204 eihef_off
= bfd_getl32 (eihd
.ext_fixup_off
);
7205 eihnp_off
= bfd_getl32 (eihd
.noopt_psect_off
);
7206 fprintf (file
, _(", ext fixup offset: %u, no_opt psect off: %u"),
7207 eihef_off
, eihnp_off
);
7209 fprintf (file
, _(", alias: %u\n"), (unsigned)bfd_getl16 (eihd
.alias
));
7213 struct vms_eihvn eihvn
;
7217 fprintf (file
, _("system version array information:\n"));
7218 if (bfd_seek (abfd
, (file_ptr
) eihvn_off
, SEEK_SET
)
7219 || bfd_bread (&eihvn
, sizeof (eihvn
), abfd
) != sizeof (eihvn
))
7221 fprintf (file
, _("cannot read EIHVN header\n"));
7224 mask
= bfd_getl32 (eihvn
.subsystem_mask
);
7225 for (j
= 0; j
< 32; j
++)
7226 if (mask
& (1 << j
))
7228 struct vms_eihvn_subversion ver
;
7229 if (bfd_bread (&ver
, sizeof (ver
), abfd
) != sizeof (ver
))
7231 fprintf (file
, _("cannot read EIHVN version\n"));
7234 fprintf (file
, _(" %02u "), j
);
7237 case EIHVN__BASE_IMAGE_BIT
:
7238 fputs (_("BASE_IMAGE "), file
);
7240 case EIHVN__MEMORY_MANAGEMENT_BIT
:
7241 fputs (_("MEMORY_MANAGEMENT"), file
);
7244 fputs (_("IO "), file
);
7246 case EIHVN__FILES_VOLUMES_BIT
:
7247 fputs (_("FILES_VOLUMES "), file
);
7249 case EIHVN__PROCESS_SCHED_BIT
:
7250 fputs (_("PROCESS_SCHED "), file
);
7252 case EIHVN__SYSGEN_BIT
:
7253 fputs (_("SYSGEN "), file
);
7255 case EIHVN__CLUSTERS_LOCKMGR_BIT
:
7256 fputs (_("CLUSTERS_LOCKMGR "), file
);
7258 case EIHVN__LOGICAL_NAMES_BIT
:
7259 fputs (_("LOGICAL_NAMES "), file
);
7261 case EIHVN__SECURITY_BIT
:
7262 fputs (_("SECURITY "), file
);
7264 case EIHVN__IMAGE_ACTIVATOR_BIT
:
7265 fputs (_("IMAGE_ACTIVATOR "), file
);
7267 case EIHVN__NETWORKS_BIT
:
7268 fputs (_("NETWORKS "), file
);
7270 case EIHVN__COUNTERS_BIT
:
7271 fputs (_("COUNTERS "), file
);
7273 case EIHVN__STABLE_BIT
:
7274 fputs (_("STABLE "), file
);
7276 case EIHVN__MISC_BIT
:
7277 fputs (_("MISC "), file
);
7279 case EIHVN__CPU_BIT
:
7280 fputs (_("CPU "), file
);
7282 case EIHVN__VOLATILE_BIT
:
7283 fputs (_("VOLATILE "), file
);
7285 case EIHVN__SHELL_BIT
:
7286 fputs (_("SHELL "), file
);
7288 case EIHVN__POSIX_BIT
:
7289 fputs (_("POSIX "), file
);
7291 case EIHVN__MULTI_PROCESSING_BIT
:
7292 fputs (_("MULTI_PROCESSING "), file
);
7294 case EIHVN__GALAXY_BIT
:
7295 fputs (_("GALAXY "), file
);
7298 fputs (_("*unknown* "), file
);
7301 fprintf (file
, _(": %u.%u\n"),
7302 (unsigned)bfd_getl16 (ver
.major
),
7303 (unsigned)bfd_getl16 (ver
.minor
));
7309 struct vms_eiha eiha
;
7311 if (bfd_seek (abfd
, (file_ptr
) eiha_off
, SEEK_SET
)
7312 || bfd_bread (&eiha
, sizeof (eiha
), abfd
) != sizeof (eiha
))
7314 fprintf (file
, _("cannot read EIHA\n"));
7317 fprintf (file
, _("Image activation: (size=%u)\n"),
7318 (unsigned)bfd_getl32 (eiha
.size
));
7319 fprintf (file
, _(" First address : 0x%08x 0x%08x\n"),
7320 (unsigned)bfd_getl32 (eiha
.tfradr1_h
),
7321 (unsigned)bfd_getl32 (eiha
.tfradr1
));
7322 fprintf (file
, _(" Second address: 0x%08x 0x%08x\n"),
7323 (unsigned)bfd_getl32 (eiha
.tfradr2_h
),
7324 (unsigned)bfd_getl32 (eiha
.tfradr2
));
7325 fprintf (file
, _(" Third address : 0x%08x 0x%08x\n"),
7326 (unsigned)bfd_getl32 (eiha
.tfradr3_h
),
7327 (unsigned)bfd_getl32 (eiha
.tfradr3
));
7328 fprintf (file
, _(" Fourth address: 0x%08x 0x%08x\n"),
7329 (unsigned)bfd_getl32 (eiha
.tfradr4_h
),
7330 (unsigned)bfd_getl32 (eiha
.tfradr4
));
7331 fprintf (file
, _(" Shared image : 0x%08x 0x%08x\n"),
7332 (unsigned)bfd_getl32 (eiha
.inishr_h
),
7333 (unsigned)bfd_getl32 (eiha
.inishr
));
7337 struct vms_eihi eihi
;
7339 if (bfd_seek (abfd
, (file_ptr
) eihi_off
, SEEK_SET
)
7340 || bfd_bread (&eihi
, sizeof (eihi
), abfd
) != sizeof (eihi
))
7342 fprintf (file
, _("cannot read EIHI\n"));
7345 fprintf (file
, _("Image identification: (major: %u, minor: %u)\n"),
7346 (unsigned)bfd_getl32 (eihi
.majorid
),
7347 (unsigned)bfd_getl32 (eihi
.minorid
));
7348 fprintf (file
, _(" image name : %.*s\n"),
7349 eihi
.imgnam
[0], eihi
.imgnam
+ 1);
7350 fprintf (file
, _(" link time : %s\n"),
7351 vms_time_to_str (eihi
.linktime
));
7352 fprintf (file
, _(" image ident : %.*s\n"),
7353 eihi
.imgid
[0], eihi
.imgid
+ 1);
7354 fprintf (file
, _(" linker ident : %.*s\n"),
7355 eihi
.linkid
[0], eihi
.linkid
+ 1);
7356 fprintf (file
, _(" image build ident: %.*s\n"),
7357 eihi
.imgbid
[0], eihi
.imgbid
+ 1);
7361 struct vms_eihs eihs
;
7363 if (bfd_seek (abfd
, (file_ptr
) eihs_off
, SEEK_SET
)
7364 || bfd_bread (&eihs
, sizeof (eihs
), abfd
) != sizeof (eihs
))
7366 fprintf (file
, _("cannot read EIHS\n"));
7369 fprintf (file
, _("Image symbol & debug table: (major: %u, minor: %u)\n"),
7370 (unsigned)bfd_getl32 (eihs
.majorid
),
7371 (unsigned)bfd_getl32 (eihs
.minorid
));
7372 dst_vbn
= bfd_getl32 (eihs
.dstvbn
);
7373 dst_size
= bfd_getl32 (eihs
.dstsize
);
7374 fprintf (file
, _(" debug symbol table : vbn: %u, size: %u\n"),
7376 gst_vbn
= bfd_getl32 (eihs
.gstvbn
);
7377 gst_size
= bfd_getl32 (eihs
.gstsize
);
7378 fprintf (file
, _(" global symbol table: vbn: %u, records: %u\n"),
7380 dmt_vbn
= bfd_getl32 (eihs
.dmtvbn
);
7381 dmt_size
= bfd_getl32 (eihs
.dmtsize
);
7382 fprintf (file
, _(" debug module table : vbn: %u, size: %u\n"),
7385 while (eisd_off
!= 0)
7387 struct vms_eisd eisd
;
7392 if (bfd_seek (abfd
, (file_ptr
) eisd_off
, SEEK_SET
)
7393 || bfd_bread (&eisd
, sizeof (eisd
), abfd
) != sizeof (eisd
))
7395 fprintf (file
, _("cannot read EISD\n"));
7398 len
= (unsigned)bfd_getl32 (eisd
.eisdsize
);
7399 if (len
!= (unsigned)-1)
7403 eisd_off
= (eisd_off
+ VMS_BLOCK_SIZE
) & ~(VMS_BLOCK_SIZE
- 1);
7405 fprintf (file
, _("Image section descriptor: (major: %u, minor: %u, "
7406 "size: %u, offset: %u)\n"),
7407 (unsigned)bfd_getl32 (eisd
.majorid
),
7408 (unsigned)bfd_getl32 (eisd
.minorid
),
7412 fprintf (file
, _(" section: base: 0x%08x%08x size: 0x%08x\n"),
7413 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 4),
7414 (unsigned)bfd_getl32 (eisd
.virt_addr
+ 0),
7415 (unsigned)bfd_getl32 (eisd
.secsize
));
7416 val
= (unsigned)bfd_getl32 (eisd
.flags
);
7417 fprintf (file
, _(" flags: 0x%04x"), val
);
7418 if (val
& EISD__M_GBL
)
7419 fprintf (file
, " GBL");
7420 if (val
& EISD__M_CRF
)
7421 fprintf (file
, " CRF");
7422 if (val
& EISD__M_DZRO
)
7423 fprintf (file
, " DZRO");
7424 if (val
& EISD__M_WRT
)
7425 fprintf (file
, " WRT");
7426 if (val
& EISD__M_INITALCODE
)
7427 fprintf (file
, " INITALCODE");
7428 if (val
& EISD__M_BASED
)
7429 fprintf (file
, " BASED");
7430 if (val
& EISD__M_FIXUPVEC
)
7431 fprintf (file
, " FIXUPVEC");
7432 if (val
& EISD__M_RESIDENT
)
7433 fprintf (file
, " RESIDENT");
7434 if (val
& EISD__M_VECTOR
)
7435 fprintf (file
, " VECTOR");
7436 if (val
& EISD__M_PROTECT
)
7437 fprintf (file
, " PROTECT");
7438 if (val
& EISD__M_LASTCLU
)
7439 fprintf (file
, " LASTCLU");
7440 if (val
& EISD__M_EXE
)
7441 fprintf (file
, " EXE");
7442 if (val
& EISD__M_NONSHRADR
)
7443 fprintf (file
, " NONSHRADR");
7444 if (val
& EISD__M_QUAD_LENGTH
)
7445 fprintf (file
, " QUAD_LENGTH");
7446 if (val
& EISD__M_ALLOC_64BIT
)
7447 fprintf (file
, " ALLOC_64BIT");
7448 fprintf (file
, "\n");
7449 if (val
& EISD__M_FIXUPVEC
)
7451 eiaf_vbn
= bfd_getl32 (eisd
.vbn
);
7452 eiaf_size
= bfd_getl32 (eisd
.secsize
);
7454 fprintf (file
, _(" vbn: %u, pfc: %u, matchctl: %u type: %u ("),
7455 (unsigned)bfd_getl32 (eisd
.vbn
),
7456 eisd
.pfc
, eisd
.matchctl
, eisd
.type
);
7459 case EISD__K_NORMAL
:
7460 fputs (_("NORMAL"), file
);
7462 case EISD__K_SHRFXD
:
7463 fputs (_("SHRFXD"), file
);
7465 case EISD__K_PRVFXD
:
7466 fputs (_("PRVFXD"), file
);
7468 case EISD__K_SHRPIC
:
7469 fputs (_("SHRPIC"), file
);
7471 case EISD__K_PRVPIC
:
7472 fputs (_("PRVPIC"), file
);
7474 case EISD__K_USRSTACK
:
7475 fputs (_("USRSTACK"), file
);
7478 fputs (_("*unknown*"), file
);
7481 fputs (_(")\n"), file
);
7482 if (val
& EISD__M_GBL
)
7483 fprintf (file
, _(" ident: 0x%08x, name: %.*s\n"),
7484 (unsigned)bfd_getl32 (eisd
.ident
),
7485 eisd
.gblnam
[0], eisd
.gblnam
+ 1);
7491 if (bfd_seek (abfd
, (file_ptr
) (dmt_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7493 fprintf (file
, _("cannot read DMT\n"));
7497 fprintf (file
, _("Debug module table:\n"));
7499 while (dmt_size
> 0)
7501 struct vms_dmt_header dmth
;
7504 if (bfd_bread (&dmth
, sizeof (dmth
), abfd
) != sizeof (dmth
))
7506 fprintf (file
, _("cannot read DMT header\n"));
7509 count
= bfd_getl16 (dmth
.psect_count
);
7511 _(" module address: 0x%08x, size: 0x%08x, (%u psect)\n"),
7512 (unsigned)bfd_getl32 (dmth
.modbeg
),
7513 (unsigned)bfd_getl32 (dmth
.size
), count
);
7514 dmt_size
-= sizeof (dmth
);
7517 struct vms_dmt_psect dmtp
;
7519 if (bfd_bread (&dmtp
, sizeof (dmtp
), abfd
) != sizeof (dmtp
))
7521 fprintf (file
, _("cannot read DMT psect\n"));
7524 fprintf (file
, _(" psect start: 0x%08x, length: %u\n"),
7525 (unsigned)bfd_getl32 (dmtp
.start
),
7526 (unsigned)bfd_getl32 (dmtp
.length
));
7528 dmt_size
-= sizeof (dmtp
);
7535 if (bfd_seek (abfd
, (file_ptr
) (dst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7537 fprintf (file
, _("cannot read DST\n"));
7541 evax_bfd_print_dst (abfd
, dst_size
, file
);
7545 if (bfd_seek (abfd
, (file_ptr
) (gst_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
))
7547 fprintf (file
, _("cannot read GST\n"));
7551 fprintf (file
, _("Global symbol table:\n"));
7552 evax_bfd_print_eobj (abfd
, file
);
7557 struct vms_eiaf
*eiaf
;
7558 unsigned int qrelfixoff
;
7559 unsigned int lrelfixoff
;
7560 unsigned int qdotadroff
;
7561 unsigned int ldotadroff
;
7562 unsigned int shrimgcnt
;
7563 unsigned int shlstoff
;
7564 unsigned int codeadroff
;
7565 unsigned int lpfixoff
;
7566 unsigned int chgprtoff
;
7568 buf
= bfd_malloc (eiaf_size
);
7570 if (bfd_seek (abfd
, (file_ptr
) (eiaf_vbn
- 1) * VMS_BLOCK_SIZE
, SEEK_SET
)
7571 || bfd_bread (buf
, eiaf_size
, abfd
) != eiaf_size
)
7573 fprintf (file
, _("cannot read EIHA\n"));
7577 eiaf
= (struct vms_eiaf
*)buf
;
7579 _("Image activator fixup: (major: %u, minor: %u)\n"),
7580 (unsigned)bfd_getl32 (eiaf
->majorid
),
7581 (unsigned)bfd_getl32 (eiaf
->minorid
));
7582 fprintf (file
, _(" iaflink : 0x%08x %08x\n"),
7583 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 0),
7584 (unsigned)bfd_getl32 (eiaf
->iaflink
+ 4));
7585 fprintf (file
, _(" fixuplnk: 0x%08x %08x\n"),
7586 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 0),
7587 (unsigned)bfd_getl32 (eiaf
->fixuplnk
+ 4));
7588 fprintf (file
, _(" size : %u\n"),
7589 (unsigned)bfd_getl32 (eiaf
->size
));
7590 fprintf (file
, _(" flags: 0x%08x\n"),
7591 (unsigned)bfd_getl32 (eiaf
->flags
));
7592 qrelfixoff
= bfd_getl32 (eiaf
->qrelfixoff
);
7593 lrelfixoff
= bfd_getl32 (eiaf
->lrelfixoff
);
7594 fprintf (file
, _(" qrelfixoff: %5u, lrelfixoff: %5u\n"),
7595 qrelfixoff
, lrelfixoff
);
7596 qdotadroff
= bfd_getl32 (eiaf
->qdotadroff
);
7597 ldotadroff
= bfd_getl32 (eiaf
->ldotadroff
);
7598 fprintf (file
, _(" qdotadroff: %5u, ldotadroff: %5u\n"),
7599 qdotadroff
, ldotadroff
);
7600 codeadroff
= bfd_getl32 (eiaf
->codeadroff
);
7601 lpfixoff
= bfd_getl32 (eiaf
->lpfixoff
);
7602 fprintf (file
, _(" codeadroff: %5u, lpfixoff : %5u\n"),
7603 codeadroff
, lpfixoff
);
7604 chgprtoff
= bfd_getl32 (eiaf
->chgprtoff
);
7605 fprintf (file
, _(" chgprtoff : %5u\n"), chgprtoff
);
7606 shrimgcnt
= bfd_getl32 (eiaf
->shrimgcnt
);
7607 shlstoff
= bfd_getl32 (eiaf
->shlstoff
);
7608 fprintf (file
, _(" shlstoff : %5u, shrimgcnt : %5u\n"),
7609 shlstoff
, shrimgcnt
);
7610 fprintf (file
, _(" shlextra : %5u, permctx : %5u\n"),
7611 (unsigned)bfd_getl32 (eiaf
->shlextra
),
7612 (unsigned)bfd_getl32 (eiaf
->permctx
));
7613 fprintf (file
, _(" base_va : 0x%08x\n"),
7614 (unsigned)bfd_getl32 (eiaf
->base_va
));
7615 fprintf (file
, _(" lppsbfixoff: %5u\n"),
7616 (unsigned)bfd_getl32 (eiaf
->lppsbfixoff
));
7620 struct vms_shl
*shl
= (struct vms_shl
*)(buf
+ shlstoff
);
7623 fprintf (file
, _(" Shareable images:\n"));
7624 for (j
= 0; j
< shrimgcnt
; j
++, shl
++)
7627 _(" %u: size: %u, flags: 0x%02x, name: %.*s\n"),
7628 j
, shl
->size
, shl
->flags
,
7629 shl
->imgnam
[0], shl
->imgnam
+ 1);
7632 if (qrelfixoff
!= 0)
7634 fprintf (file
, _(" quad-word relocation fixups:\n"));
7635 evax_bfd_print_relocation_records (file
, buf
+ qrelfixoff
, 8);
7637 if (lrelfixoff
!= 0)
7639 fprintf (file
, _(" long-word relocation fixups:\n"));
7640 evax_bfd_print_relocation_records (file
, buf
+ lrelfixoff
, 4);
7642 if (qdotadroff
!= 0)
7644 fprintf (file
, _(" quad-word .address reference fixups:\n"));
7645 evax_bfd_print_address_fixups (file
, buf
+ qdotadroff
);
7647 if (ldotadroff
!= 0)
7649 fprintf (file
, _(" long-word .address reference fixups:\n"));
7650 evax_bfd_print_address_fixups (file
, buf
+ ldotadroff
);
7652 if (codeadroff
!= 0)
7654 fprintf (file
, _(" Code Address Reference Fixups:\n"));
7655 evax_bfd_print_reference_fixups (file
, buf
+ codeadroff
);
7659 fprintf (file
, _(" Linkage Pairs Referece Fixups:\n"));
7660 evax_bfd_print_reference_fixups (file
, buf
+ lpfixoff
);
7664 unsigned int count
= (unsigned)bfd_getl32 (buf
+ chgprtoff
);
7665 struct vms_eicp
*eicp
= (struct vms_eicp
*)(buf
+ chgprtoff
+ 4);
7668 fprintf (file
, _(" Change Protection (%u entries):\n"), count
);
7669 for (j
= 0; j
< count
; j
++, eicp
++)
7671 unsigned int prot
= bfd_getl32 (eicp
->newprt
);
7673 _(" base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "),
7674 (unsigned)bfd_getl32 (eicp
->baseva
+ 4),
7675 (unsigned)bfd_getl32 (eicp
->baseva
+ 0),
7676 (unsigned)bfd_getl32 (eicp
->size
),
7677 (unsigned)bfd_getl32 (eicp
->newprt
));
7681 fprintf (file
, "NA");
7683 case PRT__C_RESERVED
:
7684 fprintf (file
, "RES");
7687 fprintf (file
, "KW");
7690 fprintf (file
, "KR");
7693 fprintf (file
, "UW");
7696 fprintf (file
, "EW");
7699 fprintf (file
, "ERKW");
7702 fprintf (file
, "ER");
7705 fprintf (file
, "SW");
7708 fprintf (file
, "SREW");
7711 fprintf (file
, "SRKW");
7714 fprintf (file
, "SR");
7717 fprintf (file
, "URSW");
7720 fprintf (file
, "UREW");
7723 fprintf (file
, "URKW");
7726 fprintf (file
, "UR");
7740 vms_bfd_print_private_bfd_data (bfd
*abfd
, void *ptr
)
7742 FILE *file
= (FILE *)ptr
;
7744 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
7745 evax_bfd_print_image (abfd
, file
);
7748 if (bfd_seek (abfd
, 0, SEEK_SET
))
7750 evax_bfd_print_eobj (abfd
, file
);
7757 /* Slurp an ordered set of VMS object records. */
7760 alpha_vms_read_sections_content (bfd
*abfd
, struct bfd_link_info
*info
)
7762 asection
*cur_section
;
7763 file_ptr cur_offset
;
7764 asection
*dst_section
;
7765 file_ptr dst_offset
;
7767 if (bfd_seek (abfd
, 0, SEEK_SET
) != 0)
7770 PRIV (image_autoextend
) = FALSE
;
7775 dst_section
= PRIV (dst_section
);
7779 if (info
->strip
== strip_all
|| info
->strip
== strip_debugger
)
7784 else if (dst_section
)
7786 dst_offset
= dst_section
->output_offset
;
7787 dst_section
= dst_section
->output_section
;
7796 type
= _bfd_vms_get_object_record (abfd
);
7799 vms_debug2 ((2, "next_record failed\n"));
7805 PRIV (image_section
) = cur_section
;
7806 PRIV (image_offset
) = cur_offset
;
7807 res
= _bfd_vms_slurp_etir (abfd
, info
);
7808 cur_section
= PRIV (image_section
);
7809 cur_offset
= PRIV (image_offset
);
7813 if (dst_section
== NULL
)
7815 PRIV (image_section
) = dst_section
;
7816 PRIV (image_offset
) = dst_offset
;
7817 PRIV (image_autoextend
) = TRUE
;
7818 res
= _bfd_vms_slurp_etir (abfd
, info
);
7819 PRIV (image_autoextend
) = FALSE
;
7820 dst_offset
= PRIV (image_offset
);
7829 vms_debug2 ((2, "slurp eobj type %d failed\n", type
));
7836 alpha_vms_sizeof_headers (bfd
*abfd ATTRIBUTE_UNUSED
,
7837 struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7842 /* Add a linkage pair fixup at address SECT + OFFSET to SHLIB. */
7845 alpha_vms_add_fixup_lp (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
->lp
, bfd_vma
,
7855 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7859 alpha_vms_add_fixup_ca (struct bfd_link_info
*info
, bfd
*src
, bfd
*shlib
)
7861 struct alpha_vms_shlib_el
*sl
;
7862 asection
*sect
= PRIV2 (src
, image_section
);
7863 file_ptr offset
= PRIV2 (src
, image_offset
);
7865 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7866 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7867 sl
->has_fixups
= TRUE
;
7868 VEC_APPEND_EL (sl
->ca
, bfd_vma
,
7869 sect
->output_section
->vma
+ sect
->output_offset
+ offset
);
7873 alpha_vms_add_fixup_qr (struct bfd_link_info
*info
, bfd
*src
,
7874 bfd
*shlib
, bfd_vma vec
)
7876 struct alpha_vms_shlib_el
*sl
;
7877 struct alpha_vms_vma_ref
*r
;
7878 asection
*sect
= PRIV2 (src
, image_section
);
7879 file_ptr offset
= PRIV2 (src
, image_offset
);
7881 sl
= &VEC_EL (alpha_vms_link_hash (info
)->shrlibs
,
7882 struct alpha_vms_shlib_el
, PRIV2 (shlib
, shr_index
));
7883 sl
->has_fixups
= TRUE
;
7884 r
= VEC_APPEND (sl
->qr
, struct alpha_vms_vma_ref
);
7885 r
->vma
= sect
->output_section
->vma
+ sect
->output_offset
+ offset
;
7890 alpha_vms_add_lw_fixup (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
7891 unsigned int shr ATTRIBUTE_UNUSED
,
7892 bfd_vma vec ATTRIBUTE_UNUSED
)
7899 alpha_vms_add_qw_fixup (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
7900 unsigned int shr ATTRIBUTE_UNUSED
,
7901 bfd_vma vec ATTRIBUTE_UNUSED
)
7908 alpha_vms_add_lw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7913 alpha_vms_add_qw_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
)
7917 static struct bfd_hash_entry
*
7918 alpha_vms_link_hash_newfunc (struct bfd_hash_entry
*entry
,
7919 struct bfd_hash_table
*table
,
7922 struct alpha_vms_link_hash_entry
*ret
=
7923 (struct alpha_vms_link_hash_entry
*) entry
;
7925 /* Allocate the structure if it has not already been allocated by a
7928 ret
= ((struct alpha_vms_link_hash_entry
*)
7929 bfd_hash_allocate (table
,
7930 sizeof (struct alpha_vms_link_hash_entry
)));
7934 /* Call the allocation method of the superclass. */
7935 ret
= ((struct alpha_vms_link_hash_entry
*)
7936 _bfd_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
7941 return (struct bfd_hash_entry
*) ret
;
7944 /* Create an Alpha/VMS link hash table. */
7946 static struct bfd_link_hash_table
*
7947 alpha_vms_bfd_link_hash_table_create (bfd
*abfd
)
7949 struct alpha_vms_link_hash_table
*ret
;
7950 bfd_size_type amt
= sizeof (struct alpha_vms_link_hash_table
);
7952 ret
= (struct alpha_vms_link_hash_table
*) bfd_malloc (amt
);
7955 if (!_bfd_link_hash_table_init (&ret
->root
, abfd
,
7956 alpha_vms_link_hash_newfunc
,
7957 sizeof (struct alpha_vms_link_hash_entry
)))
7963 VEC_INIT (ret
->shrlibs
);
7970 alpha_vms_link_add_object_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
7974 for (i
= 0; i
< PRIV (gsd_sym_count
); i
++)
7976 struct vms_symbol_entry
*e
= PRIV (syms
)[i
];
7977 struct alpha_vms_link_hash_entry
*h
;
7980 if (!alpha_vms_convert_symbol (abfd
, e
, &sym
))
7983 if ((e
->flags
& EGSY__V_DEF
) && abfd
->selective_search
)
7985 /* In selective_search mode, only add definition that are
7987 h
= (struct alpha_vms_link_hash_entry
*)bfd_link_hash_lookup
7988 (info
->hash
, sym
.name
, FALSE
, FALSE
, FALSE
);
7989 if (h
== NULL
|| h
->root
.type
!= bfd_link_hash_undefined
)
7995 if (_bfd_generic_link_add_one_symbol
7996 (info
, abfd
, sym
.name
, sym
.flags
, sym
.section
, sym
.value
,
7997 NULL
, FALSE
, FALSE
, (struct bfd_link_hash_entry
**)&h
) == FALSE
)
8000 if ((e
->flags
& EGSY__V_DEF
)
8002 && abfd
->xvec
== info
->output_bfd
->xvec
)
8006 if (abfd
->flags
& DYNAMIC
)
8008 struct alpha_vms_shlib_el
*shlib
;
8010 /* We do not want to include any of the sections in a dynamic
8011 object in the output file. See comment in elflink.c. */
8012 bfd_section_list_clear (abfd
);
8014 shlib
= VEC_APPEND (alpha_vms_link_hash (info
)->shrlibs
,
8015 struct alpha_vms_shlib_el
);
8017 VEC_INIT (shlib
->ca
);
8018 VEC_INIT (shlib
->lp
);
8019 VEC_INIT (shlib
->qr
);
8020 PRIV (shr_index
) = VEC_COUNT (alpha_vms_link_hash (info
)->shrlibs
) - 1;
8027 alpha_vms_link_add_archive_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8030 struct bfd_link_hash_entry
**pundef
;
8031 struct bfd_link_hash_entry
**next_pundef
;
8033 /* We only accept VMS libraries. */
8034 if (info
->output_bfd
->xvec
!= abfd
->xvec
)
8036 bfd_set_error (bfd_error_wrong_format
);
8040 /* The archive_pass field in the archive itself is used to
8041 initialize PASS, since we may search the same archive multiple
8043 pass
= ++abfd
->archive_pass
;
8045 /* Look through the list of undefined symbols. */
8046 for (pundef
= &info
->hash
->undefs
; *pundef
!= NULL
; pundef
= next_pundef
)
8048 struct bfd_link_hash_entry
*h
;
8049 file_ptr file_offset
;
8054 next_pundef
= &(*pundef
)->u
.undef
.next
;
8056 /* When a symbol is defined, it is not necessarily removed from
8058 if (h
->type
!= bfd_link_hash_undefined
8059 && h
->type
!= bfd_link_hash_common
)
8061 /* Remove this entry from the list, for general cleanliness
8062 and because we are going to look through the list again
8063 if we search any more libraries. We can't remove the
8064 entry if it is the tail, because that would lose any
8065 entries we add to the list later on. */
8066 if (*pundef
!= info
->hash
->undefs_tail
)
8068 *pundef
= *next_pundef
;
8069 next_pundef
= pundef
;
8074 /* Look for this symbol in the archive hash table. */
8075 file_offset
= _bfd_vms_lib_find_symbol (abfd
, h
->root
.string
);
8076 if (file_offset
== 0)
8078 /* Nothing in this slot. */
8082 element
= bfd_get_elt_at_index (abfd
, file_offset
);
8083 if (element
== NULL
)
8086 if (element
->archive_pass
== -1 || element
->archive_pass
== pass
)
8089 if (! bfd_check_format (element
, bfd_object
))
8091 element
->archive_pass
= -1;
8095 orig_element
= element
;
8096 if (bfd_is_thin_archive (abfd
))
8098 element
= _bfd_vms_lib_get_imagelib_file (element
);
8099 if (element
== NULL
|| !bfd_check_format (element
, bfd_object
))
8101 orig_element
->archive_pass
= -1;
8106 /* Unlike the generic linker, we know that this element provides
8107 a definition for an undefined symbol and we know that we want
8108 to include it. We don't need to check anything. */
8109 if (! (*info
->callbacks
->add_archive_element
) (info
, element
,
8112 if (! alpha_vms_link_add_object_symbols (element
, info
))
8115 orig_element
->archive_pass
= pass
;
8122 alpha_vms_bfd_link_add_symbols (bfd
*abfd
, struct bfd_link_info
*info
)
8124 switch (bfd_get_format (abfd
))
8127 vms_debug2 ((2, "vms_link_add_symbols for object %s\n",
8129 return alpha_vms_link_add_object_symbols (abfd
, info
);
8132 vms_debug2 ((2, "vms_link_add_symbols for archive %s\n",
8134 return alpha_vms_link_add_archive_symbols (abfd
, info
);
8137 bfd_set_error (bfd_error_wrong_format
);
8143 alpha_vms_build_fixups (struct bfd_link_info
*info
)
8145 struct alpha_vms_link_hash_table
*t
= alpha_vms_link_hash (info
);
8146 unsigned char *content
;
8148 unsigned int sz
= 0;
8149 unsigned int lp_sz
= 0;
8150 unsigned int ca_sz
= 0;
8151 unsigned int qr_sz
= 0;
8152 unsigned int shrimg_cnt
= 0;
8153 struct vms_eiaf
*eiaf
;
8157 /* Shared libraries. */
8158 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8160 struct alpha_vms_shlib_el
*shlib
;
8162 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8164 if (!shlib
->has_fixups
)
8169 if (VEC_COUNT (shlib
->ca
) > 0)
8171 /* Header + entries. */
8173 ca_sz
+= VEC_COUNT (shlib
->ca
) * 4;
8175 if (VEC_COUNT (shlib
->lp
) > 0)
8177 /* Header + entries. */
8179 lp_sz
+= VEC_COUNT (shlib
->lp
) * 4;
8181 if (VEC_COUNT (shlib
->qr
) > 0)
8183 /* Header + entries. */
8185 qr_sz
+= VEC_COUNT (shlib
->qr
) * 8;
8196 /* Finish now if there is no content. */
8197 if (ca_sz
+ lp_sz
+ qr_sz
== 0)
8200 /* Allocate section content (round-up size) */
8201 sz
= sizeof (struct vms_eiaf
) + shrimg_cnt
* sizeof (struct vms_shl
)
8202 + ca_sz
+ lp_sz
+ qr_sz
;
8203 sz
= (sz
+ VMS_BLOCK_SIZE
- 1) & ~(VMS_BLOCK_SIZE
- 1);
8204 content
= bfd_zalloc (info
->output_bfd
, sz
);
8205 if (content
== NULL
)
8208 sec
= alpha_vms_link_hash (info
)->fixup
;
8209 sec
->contents
= content
;
8212 eiaf
= (struct vms_eiaf
*)content
;
8213 off
= sizeof (struct vms_eiaf
);
8214 bfd_putl32 (0, eiaf
->majorid
);
8215 bfd_putl32 (0, eiaf
->minorid
);
8216 bfd_putl32 (0, eiaf
->iaflink
);
8217 bfd_putl32 (0, eiaf
->fixuplnk
);
8218 bfd_putl32 (sizeof (struct vms_eiaf
), eiaf
->size
);
8219 bfd_putl32 (0, eiaf
->flags
);
8220 bfd_putl32 (0, eiaf
->qrelfixoff
);
8221 bfd_putl32 (0, eiaf
->lrelfixoff
);
8222 bfd_putl32 (0, eiaf
->qdotadroff
);
8223 bfd_putl32 (0, eiaf
->ldotadroff
);
8224 bfd_putl32 (0, eiaf
->codeadroff
);
8225 bfd_putl32 (0, eiaf
->lpfixoff
);
8226 bfd_putl32 (0, eiaf
->chgprtoff
);
8227 bfd_putl32 (shrimg_cnt
? off
: 0, eiaf
->shlstoff
);
8228 bfd_putl32 (shrimg_cnt
, eiaf
->shrimgcnt
);
8229 bfd_putl32 (0, eiaf
->shlextra
);
8230 bfd_putl32 (0, eiaf
->permctx
);
8231 bfd_putl32 (0, eiaf
->base_va
);
8232 bfd_putl32 (0, eiaf
->lppsbfixoff
);
8239 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8241 struct alpha_vms_shlib_el
*shlib
;
8242 struct vms_shl
*shl
;
8244 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8246 if (!shlib
->has_fixups
)
8249 /* Renumber shared images. */
8250 PRIV2 (shlib
->abfd
, shr_index
) = shrimg_cnt
++;
8252 shl
= (struct vms_shl
*)(content
+ off
);
8253 bfd_putl32 (0, shl
->baseva
);
8254 bfd_putl32 (0, shl
->shlptr
);
8255 bfd_putl32 (0, shl
->ident
);
8256 bfd_putl32 (0, shl
->permctx
);
8257 shl
->size
= sizeof (struct vms_shl
);
8258 bfd_putl16 (0, shl
->fill_1
);
8260 bfd_putl32 (0, shl
->icb
);
8261 shl
->imgnam
[0] = strlen (PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
));
8262 memcpy (shl
->imgnam
+ 1, PRIV2 (shlib
->abfd
, hdr_data
.hdr_t_name
),
8265 off
+= sizeof (struct vms_shl
);
8271 bfd_putl32 (off
, eiaf
->codeadroff
);
8273 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8275 struct alpha_vms_shlib_el
*shlib
;
8278 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8280 if (VEC_COUNT (shlib
->ca
) == 0)
8283 bfd_putl32 (VEC_COUNT (shlib
->ca
), content
+ off
);
8284 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8287 for (j
= 0; j
< VEC_COUNT (shlib
->ca
); j
++)
8289 bfd_putl32 (VEC_EL (shlib
->ca
, bfd_vma
, j
) - t
->base_addr
,
8295 bfd_putl32 (0, content
+ off
);
8296 bfd_putl32 (0, content
+ off
+ 4);
8303 bfd_putl32 (off
, eiaf
->lpfixoff
);
8305 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8307 struct alpha_vms_shlib_el
*shlib
;
8310 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8312 if (VEC_COUNT (shlib
->lp
) == 0)
8315 bfd_putl32 (VEC_COUNT (shlib
->lp
), content
+ off
);
8316 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8319 for (j
= 0; j
< VEC_COUNT (shlib
->lp
); j
++)
8321 bfd_putl32 (VEC_EL (shlib
->lp
, bfd_vma
, j
) - t
->base_addr
,
8327 bfd_putl32 (0, content
+ off
);
8328 bfd_putl32 (0, content
+ off
+ 4);
8335 bfd_putl32 (off
, eiaf
->qdotadroff
);
8337 for (i
= 0; i
< VEC_COUNT (t
->shrlibs
); i
++)
8339 struct alpha_vms_shlib_el
*shlib
;
8342 shlib
= &VEC_EL (t
->shrlibs
, struct alpha_vms_shlib_el
, i
);
8344 if (VEC_COUNT (shlib
->qr
) == 0)
8347 bfd_putl32 (VEC_COUNT (shlib
->qr
), content
+ off
);
8348 bfd_putl32 (PRIV2 (shlib
->abfd
, shr_index
), content
+ off
+ 4);
8351 for (j
= 0; j
< VEC_COUNT (shlib
->qr
); j
++)
8353 struct alpha_vms_vma_ref
*r
;
8354 r
= &VEC_EL (shlib
->qr
, struct alpha_vms_vma_ref
, j
);
8355 bfd_putl32 (r
->vma
- t
->base_addr
, content
+ off
);
8356 bfd_putl32 (r
->ref
, content
+ off
+ 4);
8361 bfd_putl32 (0, content
+ off
);
8362 bfd_putl32 (0, content
+ off
+ 4);
8373 alpha_vms_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
8376 struct bfd_link_order
*p
;
8382 bfd_get_outsymbols (abfd
) = NULL
;
8383 bfd_get_symcount (abfd
) = 0;
8385 /* Mark all sections which will be included in the output file. */
8386 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8387 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8388 if (p
->type
== bfd_indirect_link_order
)
8389 p
->u
.indirect
.section
->linker_mark
= TRUE
;
8392 /* Handle all the link order information for the sections. */
8393 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8395 printf ("For section %s (at 0x%08x, flags=0x%08x):\n",
8396 o
->name
, (unsigned)o
->vma
, (unsigned)o
->flags
);
8398 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8400 printf (" at 0x%08x - 0x%08x: ",
8401 (unsigned)p
->offset
, (unsigned)(p
->offset
+ p
->size
- 1));
8404 case bfd_section_reloc_link_order
:
8405 case bfd_symbol_reloc_link_order
:
8406 printf (" section/symbol reloc\n");
8408 case bfd_indirect_link_order
:
8409 printf (" section %s of %s\n",
8410 p
->u
.indirect
.section
->name
,
8411 p
->u
.indirect
.section
->owner
->filename
);
8413 case bfd_data_link_order
:
8414 printf (" explicit data\n");
8417 printf (" *unknown* type %u\n", p
->type
);
8424 /* Find entry point. */
8425 if (bfd_get_start_address (abfd
) == 0)
8427 bfd
*startbfd
= NULL
;
8429 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8431 /* Consider only VMS object files. */
8432 if (sub
->xvec
!= abfd
->xvec
)
8435 if (!PRIV2 (sub
, eom_data
).eom_has_transfer
)
8437 if ((PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
) && startbfd
)
8439 if (startbfd
!= NULL
8440 && !(PRIV2 (sub
, eom_data
).eom_b_tfrflg
& EEOM__M_WKTFR
))
8442 (*info
->callbacks
->einfo
)
8443 (_("%P: multiple entry points: in modules %B and %B\n"),
8452 unsigned int ps_idx
= PRIV2 (startbfd
, eom_data
).eom_l_psindx
;
8453 bfd_vma tfradr
= PRIV2 (startbfd
, eom_data
).eom_l_tfradr
;
8456 sec
= PRIV2 (startbfd
, sections
)[ps_idx
];
8458 bfd_set_start_address
8459 (abfd
, sec
->output_section
->vma
+ sec
->output_offset
+ tfradr
);
8463 /* Allocate content. */
8464 base_addr
= (bfd_vma
)-1;
8466 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8468 if (o
->flags
& SEC_HAS_CONTENTS
)
8470 o
->contents
= bfd_alloc (abfd
, o
->size
);
8471 if (o
->contents
== NULL
)
8474 if (o
->flags
& SEC_LOAD
)
8476 if (o
->vma
< base_addr
)
8478 if (o
->vma
+ o
->size
> last_addr
)
8479 last_addr
= o
->vma
+ o
->size
;
8483 fixupsec
= bfd_make_section_anyway_with_flags
8484 (info
->output_bfd
, "$FIXUP$",
8485 SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_LINKER_CREATED
);
8486 if (fixupsec
== NULL
)
8488 last_addr
= (last_addr
+ 0xffff) & ~0xffff;
8489 fixupsec
->vma
= last_addr
;
8491 alpha_vms_link_hash (info
)->fixup
= fixupsec
;
8492 alpha_vms_link_hash (info
)->base_addr
= base_addr
;
8494 /* Read all sections from the inputs. */
8495 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link_next
)
8497 if (sub
->flags
& DYNAMIC
)
8499 alpha_vms_create_eisd_for_shared (abfd
, sub
);
8503 if (!alpha_vms_read_sections_content (sub
, info
))
8507 /* Handle all the link order information for the sections. */
8508 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
8510 for (p
= o
->map_head
.link_order
; p
!= NULL
; p
= p
->next
)
8514 case bfd_section_reloc_link_order
:
8515 case bfd_symbol_reloc_link_order
:
8518 case bfd_indirect_link_order
:
8522 if (! _bfd_default_link_order (abfd
, info
, o
, p
))
8529 /* Compute fixups. */
8530 if (!alpha_vms_build_fixups (info
))
8536 /* Read the contents of a section.
8537 buf points to a buffer of buf_size bytes to be filled with
8538 section data (starting at offset into section) */
8541 alpha_vms_get_section_contents (bfd
*abfd
, asection
*section
,
8542 void *buf
, file_ptr offset
,
8543 bfd_size_type count
)
8547 /* Image are easy. */
8548 if (bfd_get_file_flags (abfd
) & (EXEC_P
| DYNAMIC
))
8549 return _bfd_generic_get_section_contents (abfd
, section
,
8550 buf
, offset
, count
);
8553 if (offset
+ count
< count
8554 || offset
+ count
> section
->size
)
8556 bfd_set_error (bfd_error_invalid_operation
);
8560 /* Alloc in memory and read ETIRs. */
8561 BFD_ASSERT (section
->contents
== NULL
);
8563 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8565 BFD_ASSERT (sec
->contents
== NULL
);
8567 if (sec
->size
!= 0 && (sec
->flags
& SEC_HAS_CONTENTS
))
8569 sec
->contents
= bfd_alloc (abfd
, sec
->size
);
8570 if (sec
->contents
== NULL
)
8574 if (!alpha_vms_read_sections_content (abfd
, NULL
))
8576 for (sec
= abfd
->sections
; sec
; sec
= sec
->next
)
8577 if (section
->contents
)
8578 section
->flags
|= SEC_IN_MEMORY
;
8579 memcpy (buf
, section
->contents
+ offset
, count
);
8584 /* Set the format of a file being written. */
8587 alpha_vms_mkobject (bfd
* abfd
)
8589 const bfd_arch_info_type
*arch
;
8591 vms_debug2 ((1, "alpha_vms_mkobject (%p)\n", abfd
));
8593 if (!vms_initialize (abfd
))
8596 PRIV (recwr
.buf
) = bfd_alloc (abfd
, MAX_OUTREC_SIZE
);
8597 if (PRIV (recwr
.buf
) == NULL
)
8600 arch
= bfd_scan_arch ("alpha");
8604 bfd_set_error (bfd_error_wrong_format
);
8608 abfd
->arch_info
= arch
;
8615 /* Called when the BFD is being closed to do any necessary cleanup. */
8618 vms_close_and_cleanup (bfd
* abfd
)
8620 vms_debug2 ((1, "vms_close_and_cleanup (%p)\n", abfd
));
8622 if (abfd
== NULL
|| abfd
->tdata
.any
== NULL
)
8625 if (abfd
->format
== bfd_archive
)
8627 bfd_release (abfd
, abfd
->tdata
.any
);
8628 abfd
->tdata
.any
= NULL
;
8632 if (PRIV (recrd
.buf
) != NULL
)
8633 free (PRIV (recrd
.buf
));
8635 if (PRIV (sections
) != NULL
)
8636 free (PRIV (sections
));
8638 bfd_release (abfd
, abfd
->tdata
.any
);
8639 abfd
->tdata
.any
= NULL
;
8642 if (abfd
->direction
== write_direction
)
8644 /* Last step on VMS is to convert the file to variable record length
8646 if (bfd_cache_close (abfd
) != TRUE
)
8648 if (vms_convert_to_var_unix_filename (abfd
->filename
) != TRUE
)
8656 /* Called when a new section is created. */
8659 vms_new_section_hook (bfd
* abfd
, asection
*section
)
8663 /* Count hasn't been incremented yet. */
8664 unsigned int section_count
= abfd
->section_count
+ 1;
8666 vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
8667 abfd
, section
->index
, section
->name
, section_count
));
8669 bfd_set_section_alignment (abfd
, section
, 0);
8671 if (section_count
> PRIV (section_count
))
8673 amt
= section_count
;
8674 amt
*= sizeof (asection
*);
8675 PRIV (sections
) = bfd_realloc_or_free (PRIV (sections
), amt
);
8676 if (PRIV (sections
) == NULL
)
8678 PRIV (section_count
) = section_count
;
8681 vms_debug2 ((6, "section_count: %d\n", PRIV (section_count
)));
8683 PRIV (sections
)[section
->index
] = section
;
8685 vms_debug2 ((7, "%d: %s\n", section
->index
, section
->name
));
8687 amt
= sizeof (struct vms_section_data_struct
);
8688 section
->used_by_bfd
= (PTR
) bfd_zalloc (abfd
, amt
);
8689 if (section
->used_by_bfd
== NULL
)
8692 if (strcmp (bfd_get_section_name (abfd
, section
), "$DST$") == 0)
8693 PRIV (dst_section
) = section
;
8695 /* Create the section symbol. */
8696 return _bfd_generic_new_section_hook (abfd
, section
);
8699 /* Part 4.5, symbols. */
8701 /* Print symbol to file according to how. how is one of
8702 bfd_print_symbol_name just print the name
8703 bfd_print_symbol_more print more (???)
8704 bfd_print_symbol_all print all we know, which is not much right now :-). */
8707 vms_print_symbol (bfd
* abfd
,
8710 bfd_print_symbol_type how
)
8712 vms_debug2 ((1, "vms_print_symbol (%p, %p, %p, %d)\n",
8713 abfd
, file
, symbol
, how
));
8717 case bfd_print_symbol_name
:
8718 case bfd_print_symbol_more
:
8719 fprintf ((FILE *)file
," %s", symbol
->name
);
8722 case bfd_print_symbol_all
:
8724 const char *section_name
= symbol
->section
->name
;
8726 bfd_print_symbol_vandf (abfd
, file
, symbol
);
8728 fprintf ((FILE *) file
," %-8s %s", section_name
, symbol
->name
);
8734 /* Return information about symbol in ret.
8736 fill type, value and name
8739 B bss segment symbol
8741 D data segment symbol
8743 t a static function symbol
8744 T text segment symbol
8749 vms_get_symbol_info (bfd
* abfd ATTRIBUTE_UNUSED
,
8755 vms_debug2 ((1, "vms_get_symbol_info (%p, %p, %p)\n", abfd
, symbol
, ret
));
8757 sec
= symbol
->section
;
8764 else if (bfd_is_com_section (sec
))
8766 else if (bfd_is_abs_section (sec
))
8768 else if (bfd_is_und_section (sec
))
8770 else if (bfd_is_ind_section (sec
))
8772 else if (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
)
8774 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
8776 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
8781 if (ret
->type
!= 'U')
8782 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
8785 ret
->name
= symbol
->name
;
8788 /* Return TRUE if the given symbol sym in the BFD abfd is
8789 a compiler generated local label, else return FALSE. */
8792 vms_bfd_is_local_label_name (bfd
* abfd ATTRIBUTE_UNUSED
,
8795 vms_debug2 ((1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd
, name
));
8796 return name
[0] == '$';
8799 /* Part 4.7, writing an object file. */
8801 /* Sets the contents of the section section in BFD abfd to the data starting
8802 in memory at LOCATION. The data is written to the output section starting
8803 at offset offset for count bytes.
8805 Normally TRUE is returned, else FALSE. Possible error returns are:
8806 o bfd_error_no_contents - The output section does not have the
8807 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
8808 o and some more too */
8811 _bfd_vms_set_section_contents (bfd
* abfd
,
8813 const void * location
,
8815 bfd_size_type count
)
8817 if (section
->contents
== NULL
)
8819 section
->contents
= bfd_alloc (abfd
, section
->size
);
8820 if (section
->contents
== NULL
)
8823 memcpy (section
->contents
+ offset
, location
, (size_t) count
);
8829 /* Set the architecture and machine type in BFD abfd to arch and mach.
8830 Find the correct pointer to a structure and insert it into the arch_info
8834 alpha_vms_set_arch_mach (bfd
*abfd
,
8835 enum bfd_architecture arch
, unsigned long mach
)
8837 if (arch
!= bfd_arch_alpha
8838 && arch
!= bfd_arch_unknown
)
8841 return bfd_default_set_arch_mach (abfd
, arch
, mach
);
8844 /* Set section VMS flags. Clear NO_FLAGS and set FLAGS. */
8847 bfd_vms_set_section_flags (bfd
*abfd ATTRIBUTE_UNUSED
,
8848 asection
*sec
, flagword no_flags
, flagword flags
)
8850 vms_section_data (sec
)->no_flags
= no_flags
;
8851 vms_section_data (sec
)->flags
= flags
;
8854 struct vms_private_data_struct
*
8855 bfd_vms_get_data (bfd
*abfd
)
8857 return (struct vms_private_data_struct
*)abfd
->tdata
.any
;
8860 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
8861 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
8862 #define vms_bfd_copy_link_hash_symbol_type \
8863 _bfd_generic_copy_link_hash_symbol_type
8864 #define vms_bfd_is_group_section bfd_generic_is_group_section
8865 #define vms_bfd_discard_group bfd_generic_discard_group
8866 #define vms_section_already_linked _bfd_generic_section_already_linked
8867 #define vms_bfd_define_common_symbol bfd_generic_define_common_symbol
8868 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
8870 #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
8871 #define vms_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
8872 #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
8873 #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
8874 #define vms_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
8875 #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
8877 /* Symbols table. */
8878 #define alpha_vms_make_empty_symbol _bfd_generic_make_empty_symbol
8879 #define alpha_vms_bfd_is_target_special_symbol \
8880 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
8881 #define alpha_vms_print_symbol vms_print_symbol
8882 #define alpha_vms_get_symbol_info vms_get_symbol_info
8883 #define alpha_vms_read_minisymbols _bfd_generic_read_minisymbols
8884 #define alpha_vms_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
8885 #define alpha_vms_get_lineno _bfd_nosymbols_get_lineno
8886 #define alpha_vms_find_inliner_info _bfd_nosymbols_find_inliner_info
8887 #define alpha_vms_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
8888 #define alpha_vms_find_nearest_line _bfd_vms_find_nearest_dst_line
8889 #define alpha_vms_bfd_is_local_label_name vms_bfd_is_local_label_name
8891 /* Generic table. */
8892 #define alpha_vms_close_and_cleanup vms_close_and_cleanup
8893 #define alpha_vms_bfd_free_cached_info vms_bfd_free_cached_info
8894 #define alpha_vms_new_section_hook vms_new_section_hook
8895 #define alpha_vms_set_section_contents _bfd_vms_set_section_contents
8896 #define alpha_vms_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
8898 #define alpha_vms_bfd_get_relocated_section_contents \
8899 bfd_generic_get_relocated_section_contents
8901 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
8902 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
8903 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
8904 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
8905 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
8906 #define alpha_vms_section_already_linked \
8907 _bfd_generic_section_already_linked
8909 #define alpha_vms_bfd_define_common_symbol bfd_generic_define_common_symbol
8910 #define alpha_vms_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
8911 #define alpha_vms_bfd_link_just_syms _bfd_generic_link_just_syms
8912 #define alpha_vms_bfd_copy_link_hash_symbol_type \
8913 _bfd_generic_copy_link_hash_symbol_type
8915 #define alpha_vms_bfd_link_split_section _bfd_generic_link_split_section
8917 #define alpha_vms_get_dynamic_symtab_upper_bound \
8918 _bfd_nodynamic_get_dynamic_symtab_upper_bound
8919 #define alpha_vms_canonicalize_dynamic_symtab \
8920 _bfd_nodynamic_canonicalize_dynamic_symtab
8921 #define alpha_vms_get_dynamic_reloc_upper_bound \
8922 _bfd_nodynamic_get_dynamic_reloc_upper_bound
8923 #define alpha_vms_canonicalize_dynamic_reloc \
8924 _bfd_nodynamic_canonicalize_dynamic_reloc
8926 const bfd_target vms_alpha_vec
=
8928 "vms-alpha", /* Name. */
8929 bfd_target_evax_flavour
,
8930 BFD_ENDIAN_LITTLE
, /* Data byte order is little. */
8931 BFD_ENDIAN_LITTLE
, /* Header byte order is little. */
8933 (HAS_RELOC
| EXEC_P
| HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
8934 | WP_TEXT
| D_PAGED
), /* Object flags. */
8935 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
8936 | SEC_READONLY
| SEC_CODE
| SEC_DATA
8937 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* Sect flags. */
8938 0, /* symbol_leading_char. */
8939 ' ', /* ar_pad_char. */
8940 15, /* ar_max_namelen. */
8941 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
8942 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
8943 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
8944 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
8945 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
8946 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
8948 {_bfd_dummy_target
, alpha_vms_object_p
, /* bfd_check_format. */
8949 _bfd_vms_lib_alpha_archive_p
, _bfd_dummy_target
},
8950 {bfd_false
, alpha_vms_mkobject
, /* bfd_set_format. */
8951 _bfd_vms_lib_mkarchive
, bfd_false
},
8952 {bfd_false
, alpha_vms_write_object_contents
, /* bfd_write_contents. */
8953 _bfd_vms_lib_write_archive_contents
, bfd_false
},
8955 BFD_JUMP_TABLE_GENERIC (alpha_vms
),
8956 BFD_JUMP_TABLE_COPY (vms
),
8957 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
8958 BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib
),
8959 BFD_JUMP_TABLE_SYMBOLS (alpha_vms
),
8960 BFD_JUMP_TABLE_RELOCS (alpha_vms
),
8961 BFD_JUMP_TABLE_WRITE (alpha_vms
),
8962 BFD_JUMP_TABLE_LINK (alpha_vms
),
8963 BFD_JUMP_TABLE_DYNAMIC (alpha_vms
),