1 /* vms.c -- BFD back-end for VAX (openVMS/VAX) and
2 EVAX (openVMS/Alpha) files.
3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 Free Software Foundation, Inc.
6 Written by Klaus K"ampf (kkaempf@rmi.de)
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 static boolean vms_initialize
PARAMS ((bfd
*));
30 static unsigned int priv_section_count
;
31 static boolean fill_section_ptr
PARAMS ((struct bfd_hash_entry
*, PTR
));
32 static boolean vms_fixup_sections
PARAMS ((bfd
*));
33 static boolean copy_symbols
PARAMS ((struct bfd_hash_entry
*, PTR
));
34 static bfd_reloc_status_type reloc_nil
35 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
36 static const struct bfd_target
*vms_object_p
PARAMS ((bfd
*abfd
));
37 static const struct bfd_target
*vms_archive_p
PARAMS ((bfd
*abfd
));
38 static boolean vms_mkobject
PARAMS ((bfd
*abfd
));
39 static boolean vms_write_object_contents
PARAMS ((bfd
*abfd
));
40 static boolean vms_close_and_cleanup
PARAMS ((bfd
*abfd
));
41 static boolean vms_bfd_free_cached_info
PARAMS ((bfd
*abfd
));
42 static boolean vms_new_section_hook
PARAMS ((bfd
*abfd
, asection
*section
));
43 static boolean vms_get_section_contents
44 PARAMS ((bfd
*abfd
, asection
*section
, PTR x1
, file_ptr x2
,
46 static boolean vms_get_section_contents_in_window
47 PARAMS ((bfd
*abfd
, asection
*section
, bfd_window
*w
, file_ptr offset
,
48 bfd_size_type count
));
49 static boolean vms_bfd_copy_private_bfd_data
PARAMS ((bfd
*src
, bfd
*dest
));
50 static boolean vms_bfd_copy_private_section_data
51 PARAMS ((bfd
*srcbfd
, asection
*srcsec
, bfd
*dstbfd
, asection
*dstsec
));
52 static boolean vms_bfd_copy_private_symbol_data
53 PARAMS ((bfd
*ibfd
, asymbol
*isym
, bfd
*obfd
, asymbol
*osym
));
54 static boolean vms_bfd_print_private_bfd_data
55 PARAMS ((bfd
*abfd
, void *file
));
56 static char *vms_core_file_failing_command
PARAMS ((bfd
*abfd
));
57 static int vms_core_file_failing_signal
PARAMS ((bfd
*abfd
));
58 static boolean vms_core_file_matches_executable_p
59 PARAMS ((bfd
*abfd
, bfd
*bbfd
));
60 static boolean vms_slurp_armap
PARAMS ((bfd
*abfd
));
61 static boolean vms_slurp_extended_name_table
PARAMS ((bfd
*abfd
));
62 static boolean vms_construct_extended_name_table
63 PARAMS ((bfd
*abfd
, char **tabloc
, bfd_size_type
*tablen
,
65 static void vms_truncate_arname
66 PARAMS ((bfd
*abfd
, const char *pathname
, char *arhdr
));
67 static boolean vms_write_armap
68 PARAMS ((bfd
*arch
, unsigned int elength
, struct orl
*map
,
69 unsigned int orl_count
, int stridx
));
70 static PTR vms_read_ar_hdr
PARAMS ((bfd
*abfd
));
71 static bfd
*vms_get_elt_at_index
PARAMS ((bfd
*abfd
, symindex index
));
72 static bfd
*vms_openr_next_archived_file
PARAMS ((bfd
*arch
, bfd
*prev
));
73 static boolean vms_update_armap_timestamp
PARAMS ((bfd
*abfd
));
74 static int vms_generic_stat_arch_elt
PARAMS ((bfd
*, struct stat
*));
75 static long vms_get_symtab_upper_bound
PARAMS ((bfd
*abfd
));
76 static long vms_get_symtab
PARAMS ((bfd
*abfd
, asymbol
**symbols
));
77 static void vms_print_symbol
78 PARAMS ((bfd
*abfd
, PTR file
, asymbol
*symbol
, bfd_print_symbol_type how
));
79 static void vms_get_symbol_info
80 PARAMS ((bfd
*abfd
, asymbol
*symbol
, symbol_info
*ret
));
81 static boolean vms_bfd_is_local_label_name
PARAMS ((bfd
*abfd
, const char *));
82 static alent
*vms_get_lineno
PARAMS ((bfd
*abfd
, asymbol
*symbol
));
83 static boolean vms_find_nearest_line
84 PARAMS ((bfd
*abfd
, asection
*section
, asymbol
**symbols
, bfd_vma offset
,
85 const char **file
, const char **func
, unsigned int *line
));
86 static asymbol
*vms_bfd_make_debug_symbol
87 PARAMS ((bfd
*abfd
, void *ptr
, unsigned long size
));
88 static long vms_read_minisymbols
89 PARAMS ((bfd
*abfd
, boolean dynamic
, PTR
*minisymsp
, unsigned int *sizep
));
90 static asymbol
*vms_minisymbol_to_symbol
91 PARAMS ((bfd
*abfd
, boolean dynamic
, const PTR minisym
, asymbol
*sym
));
92 static long vms_get_reloc_upper_bound
PARAMS ((bfd
*abfd
, asection
*sect
));
93 static long vms_canonicalize_reloc
94 PARAMS ((bfd
*abfd
, asection
*srcsec
, arelent
**location
,
96 static const struct reloc_howto_struct
*vms_bfd_reloc_type_lookup
97 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type code
));
98 static boolean vms_set_arch_mach
99 PARAMS ((bfd
*abfd
, enum bfd_architecture arch
, unsigned long mach
));
100 static boolean vms_set_section_contents
101 PARAMS ((bfd
*abfd
, asection
*section
, PTR location
, file_ptr offset
,
102 bfd_size_type count
));
103 static int vms_sizeof_headers
PARAMS ((bfd
*abfd
, boolean reloc
));
104 static bfd_byte
*vms_bfd_get_relocated_section_contents
105 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
,
106 struct bfd_link_order
*link_order
, bfd_byte
*data
,
107 boolean relocateable
, asymbol
**symbols
));
108 static boolean vms_bfd_relax_section
109 PARAMS ((bfd
*abfd
, asection
*section
, struct bfd_link_info
*link_info
,
111 static boolean vms_bfd_gc_sections
112 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
113 static boolean vms_bfd_merge_sections
114 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
115 static struct bfd_link_hash_table
*vms_bfd_link_hash_table_create
116 PARAMS ((bfd
*abfd
));
117 static void vms_bfd_link_hash_table_free
118 PARAMS ((struct bfd_link_hash_table
*hash
));
119 static boolean vms_bfd_link_add_symbols
120 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
121 static boolean vms_bfd_final_link
122 PARAMS ((bfd
*abfd
, struct bfd_link_info
*link_info
));
123 static boolean vms_bfd_link_split_section
124 PARAMS ((bfd
*abfd
, asection
*section
));
125 static long vms_get_dynamic_symtab_upper_bound
PARAMS ((bfd
*abfd
));
126 static long vms_canonicalize_dynamic_symtab
127 PARAMS ((bfd
*abfd
, asymbol
**symbols
));
128 static long vms_get_dynamic_reloc_upper_bound
PARAMS ((bfd
*abfd
));
129 static long vms_canonicalize_dynamic_reloc
130 PARAMS ((bfd
*abfd
, arelent
**arel
, asymbol
**symbols
));
131 static boolean vms_bfd_merge_private_bfd_data
PARAMS ((bfd
*ibfd
, bfd
*obfd
));
132 static boolean vms_bfd_set_private_flags
PARAMS ((bfd
*abfd
, flagword flags
));
134 #define vms_make_empty_symbol _bfd_generic_make_empty_symbol
135 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
137 /*===========================================================================*/
139 const bfd_target vms_alpha_vec
=
141 "vms-alpha", /* name */
142 bfd_target_evax_flavour
,
143 BFD_ENDIAN_LITTLE
, /* data byte order is little */
144 BFD_ENDIAN_LITTLE
, /* header byte order is little */
146 (HAS_RELOC
| HAS_SYMS
147 | WP_TEXT
| D_PAGED
), /* object flags */
148 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
149 | SEC_READONLY
| SEC_CODE
| SEC_DATA
150 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* sect flags */
151 0, /* symbol_leading_char */
152 ' ', /* ar_pad_char */
153 15, /* ar_max_namelen */
154 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
155 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
156 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
157 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
158 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
159 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
,
161 {_bfd_dummy_target
, vms_object_p
, /* bfd_check_format */
162 vms_archive_p
, _bfd_dummy_target
},
163 {bfd_false
, vms_mkobject
, /* bfd_set_format */
164 _bfd_generic_mkarchive
, bfd_false
},
165 {bfd_false
, vms_write_object_contents
, /* bfd_write_contents */
166 _bfd_write_archive_contents
, bfd_false
},
168 BFD_JUMP_TABLE_GENERIC (vms
),
169 BFD_JUMP_TABLE_COPY (vms
),
170 BFD_JUMP_TABLE_CORE (vms
),
171 BFD_JUMP_TABLE_ARCHIVE (vms
),
172 BFD_JUMP_TABLE_SYMBOLS (vms
),
173 BFD_JUMP_TABLE_RELOCS (vms
),
174 BFD_JUMP_TABLE_WRITE (vms
),
175 BFD_JUMP_TABLE_LINK (vms
),
176 BFD_JUMP_TABLE_DYNAMIC (vms
),
183 const bfd_target vms_vax_vec
=
185 "vms-vax", /* name */
186 bfd_target_ovax_flavour
,
187 BFD_ENDIAN_LITTLE
, /* data byte order is little */
188 BFD_ENDIAN_LITTLE
, /* header byte order is little */
190 (HAS_RELOC
| HAS_SYMS
/* object flags */
192 | HAS_LINENO
| HAS_DEBUG
| HAS_LOCALS
),
194 (SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
195 | SEC_READONLY
| SEC_CODE
| SEC_DATA
196 | SEC_HAS_CONTENTS
| SEC_IN_MEMORY
), /* sect flags */
197 0, /* symbol_leading_char */
198 ' ', /* ar_pad_char */
199 15, /* ar_max_namelen */
200 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
201 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
202 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
203 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
204 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
205 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
207 {_bfd_dummy_target
, vms_object_p
, /* bfd_check_format */
208 vms_archive_p
, _bfd_dummy_target
},
209 {bfd_false
, vms_mkobject
, /* bfd_set_format */
210 _bfd_generic_mkarchive
, bfd_false
},
211 {bfd_false
, vms_write_object_contents
, /* bfd_write_contents */
212 _bfd_write_archive_contents
, bfd_false
},
214 BFD_JUMP_TABLE_GENERIC (vms
),
215 BFD_JUMP_TABLE_COPY (vms
),
216 BFD_JUMP_TABLE_CORE (vms
),
217 BFD_JUMP_TABLE_ARCHIVE (vms
),
218 BFD_JUMP_TABLE_SYMBOLS (vms
),
219 BFD_JUMP_TABLE_RELOCS (vms
),
220 BFD_JUMP_TABLE_WRITE (vms
),
221 BFD_JUMP_TABLE_LINK (vms
),
222 BFD_JUMP_TABLE_DYNAMIC (vms
),
229 /*===========================================================================*/
231 /* Initialize private data */
234 vms_initialize (abfd
)
240 if (abfd
->tdata
.any
!= 0)
243 bfd_set_start_address (abfd
, (bfd_vma
) -1);
245 amt
= sizeof (struct vms_private_data_struct
);
246 abfd
->tdata
.any
= (struct vms_private_data_struct
*) bfd_malloc (amt
);
247 if (abfd
->tdata
.any
== 0)
257 PRIV (rec_length
) = 0;
258 PRIV (file_format
) = FF_UNKNOWN
;
259 PRIV (fixup_done
) = false;
260 PRIV (sections
) = NULL
;
262 amt
= sizeof (struct stack_struct
) * STACKSIZE
;
263 PRIV (stack
) = (struct stack_struct
*) bfd_malloc (amt
);
264 if (PRIV (stack
) == 0)
267 free (abfd
->tdata
.any
);
273 amt
= sizeof (struct bfd_hash_table
);
274 PRIV (vms_symbol_table
) = (struct bfd_hash_table
*) bfd_malloc (amt
);
275 if (PRIV (vms_symbol_table
) == 0)
280 goto vms_init_no_mem1
;
283 if (!bfd_hash_table_init (PRIV (vms_symbol_table
), _bfd_vms_hash_newfunc
))
286 amt
= sizeof (struct location_struct
) * LOCATION_SAVE_SIZE
;
287 PRIV (location_stack
) = (struct location_struct
*) bfd_malloc (amt
);
288 if (PRIV (location_stack
) == 0)
291 free (PRIV (vms_symbol_table
));
292 PRIV (vms_symbol_table
) = 0;
293 goto vms_init_no_mem2
;
296 for (i
= 0; i
< VMS_SECTION_COUNT
; i
++)
297 PRIV (vms_section_table
)[i
] = NULL
;
299 PRIV (output_buf
) = (unsigned char *) malloc (MAX_OUTREC_SIZE
);
300 if (PRIV (output_buf
) == 0)
302 free (PRIV (location_stack
));
303 PRIV (location_stack
) = 0;
304 goto vms_init_no_mem3
;
306 PRIV (push_level
) = 0;
307 PRIV (pushed_size
) = 0;
308 PRIV (length_pos
) = 2;
309 PRIV (output_size
) = 0;
310 PRIV (output_alignment
) = 1;
315 /* Fill symbol->section with section ptr
316 symbol->section is filled with the section index for defined symbols
317 during reading the GSD/EGSD section. But we need the pointer to the
320 It has the correct value for referenced (undefined section) symbols
322 called from bfd_hash_traverse in vms_fixup_sections */
325 fill_section_ptr (entry
, sections
)
326 struct bfd_hash_entry
*entry
;
332 sym
= ((vms_symbol_entry
*)entry
)->symbol
;
336 vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym
, sec
);
339 /* fill forward references (these contain section number, not section ptr). */
341 if ((unsigned int) sec
< priv_section_count
)
343 sec
= ((vms_symbol_entry
*)entry
)->symbol
->section
=
344 ((asection
**)sections
)[(int)sec
];
347 if (strcmp (sym
->name
, sec
->name
) == 0)
348 sym
->flags
|= BSF_SECTION_SYM
;
354 set up all pointers and arrays, counters and sizes are fixed now
356 we build a private sections vector for easy access since sections
357 are always referenced by an index number.
359 alloc PRIV(sections) according to abfd->section_count
360 copy abfd->sections to PRIV(sections) */
363 vms_fixup_sections (abfd
)
366 if (PRIV (fixup_done
))
370 * traverse symbol table and fill in all section pointers
373 /* can't provide section count as argument to fill_section_ptr(). */
374 priv_section_count
= PRIV (section_count
);
375 bfd_hash_traverse (PRIV (vms_symbol_table
), fill_section_ptr
,
376 (PTR
) (PRIV (sections
)));
378 PRIV (fixup_done
) = true;
383 /*===========================================================================*/
385 /* Check the format for a file being read.
386 Return a (bfd_target *) if it's an object file or zero if not. */
388 static const struct bfd_target
*
394 const struct bfd_target
*target_vector
= 0;
395 const bfd_arch_info_type
*arch
= 0;
398 vms_debug (1, "vms_object_p(%p)\n", abfd
);
401 if (!vms_initialize (abfd
))
403 fprintf (stderr
, "vms_initialize () failed !!\n");
407 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
))
409 bfd_set_error (bfd_error_file_truncated
);
418 vms_debug (7, "reading at %08lx\n", bfd_tell(abfd
));
420 if (_bfd_vms_next_record (abfd
) < 0)
423 vms_debug (2, "next_record failed\n");
425 bfd_set_error (bfd_error_wrong_format
);
429 if ((prev_type
== EOBJ_S_C_EGSD
)
430 && (PRIV (rec_type
) != EOBJ_S_C_EGSD
))
432 if (vms_fixup_sections (abfd
) == false)
435 vms_debug (2, "vms_fixup_sections failed\n");
437 bfd_set_error (bfd_error_wrong_format
);
442 prev_type
= PRIV (rec_type
);
444 if (target_vector
== 0)
446 if (prev_type
<= OBJ_S_C_MAXRECTYP
)
447 target_vector
= &vms_vax_vec
;
449 target_vector
= &vms_alpha_vec
;
456 err
= _bfd_vms_slurp_hdr (abfd
, prev_type
);
461 err
= _bfd_vms_slurp_eom (abfd
, prev_type
);
465 err
= _bfd_vms_slurp_gsd (abfd
, prev_type
);
469 err
= _bfd_vms_slurp_tir (abfd
, prev_type
);
473 err
= _bfd_vms_slurp_dbg (abfd
, prev_type
);
477 err
= _bfd_vms_slurp_tbt (abfd
, prev_type
);
480 err
= _bfd_vms_slurp_lnk (abfd
, prev_type
);
488 vms_debug (2, "slurp type %d failed with %d\n", prev_type
, err
);
490 bfd_set_error (bfd_error_wrong_format
);
494 while ((prev_type
!= EOBJ_S_C_EEOM
) && (prev_type
!= OBJ_S_C_EOM
) && (prev_type
!= OBJ_S_C_EOMW
));
496 if (target_vector
== &vms_vax_vec
)
498 if (vms_fixup_sections (abfd
) == false)
501 vms_debug (2, "vms_fixup_sections failed\n");
503 bfd_set_error (bfd_error_wrong_format
);
507 /* set arch_info to vax */
509 arch
= bfd_scan_arch ("vax");
512 vms_debug (2, "arch is vax\n");
515 else if (target_vector
== &vms_alpha_vec
)
517 /* set arch_info to alpha */
519 arch
= bfd_scan_arch ("alpha");
522 vms_debug (2, "arch is alpha\n");
529 vms_debug (2, "arch not found\n");
531 bfd_set_error (bfd_error_wrong_format
);
534 abfd
->arch_info
= arch
;
536 return target_vector
;
539 /* Check the format for a file being read.
540 Return a (bfd_target *) if it's an archive file or zero. */
542 static const struct bfd_target
*
544 bfd
*abfd ATTRIBUTE_UNUSED
;
547 vms_debug (1, "vms_archive_p(%p)\n", abfd
);
553 /* Set the format of a file being written. */
560 vms_debug (1, "vms_mkobject(%p)\n", abfd
);
563 if (!vms_initialize (abfd
))
565 fprintf (stderr
, "vms_initialize () failed !!\n");
571 const bfd_arch_info_type
*arch
= bfd_scan_arch ("vax");
573 const bfd_arch_info_type
*arch
= bfd_scan_arch ("alpha");
577 bfd_set_error(bfd_error_wrong_format
);
580 abfd
->arch_info
= arch
;
586 /* Write cached information into a file being written, at bfd_close. */
589 vms_write_object_contents (abfd
)
593 vms_debug (1, "vms_write_object_contents(%p)\n", abfd
);
596 if (abfd
->section_count
> 0) /* we have sections */
600 if (_bfd_vms_write_hdr (abfd
, OBJ_S_C_HDR
) != 0)
602 if (_bfd_vms_write_gsd (abfd
, OBJ_S_C_GSD
) != 0)
604 if (_bfd_vms_write_tir (abfd
, OBJ_S_C_TIR
) != 0)
606 if (_bfd_vms_write_tbt (abfd
, OBJ_S_C_TBT
) != 0)
608 if (_bfd_vms_write_dbg (abfd
, OBJ_S_C_DBG
) != 0)
610 if (abfd
->section_count
> 255)
612 if (_bfd_vms_write_eom (abfd
, OBJ_S_C_EOMW
) != 0)
617 if (_bfd_vms_write_eom (abfd
, OBJ_S_C_EOM
) != 0)
623 if (_bfd_vms_write_hdr (abfd
, EOBJ_S_C_EMH
) != 0)
625 if (_bfd_vms_write_gsd (abfd
, EOBJ_S_C_EGSD
) != 0)
627 if (_bfd_vms_write_tir (abfd
, EOBJ_S_C_ETIR
) != 0)
629 if (_bfd_vms_write_tbt (abfd
, EOBJ_S_C_ETBT
) != 0)
631 if (_bfd_vms_write_dbg (abfd
, EOBJ_S_C_EDBG
) != 0)
633 if (_bfd_vms_write_eom (abfd
, EOBJ_S_C_EEOM
) != 0)
640 /*-- 4.1, generic -----------------------------------------------------------*/
642 /* Called when the BFD is being closed to do any necessary cleanup. */
645 vms_close_and_cleanup (abfd
)
649 vms_section
*es
, *es1
;
653 vms_debug (1, "vms_close_and_cleanup(%p)\n", abfd
);
658 if (PRIV (vms_buf
) != NULL
)
660 free (PRIV (vms_buf
));
661 PRIV (vms_buf
) = NULL
;
665 if (PRIV (output_buf
) != 0)
667 free (PRIV (output_buf
));
668 PRIV (output_buf
) = 0;
671 sec
= abfd
->sections
;
675 free (sec
->contents
);
679 if (PRIV (sections
) != NULL
)
681 free (PRIV (sections
));
682 PRIV (sections
) = NULL
;
685 if (PRIV (vms_symbol_table
))
687 bfd_hash_table_free (PRIV (vms_symbol_table
));
688 PRIV (vms_symbol_table
) = 0;
697 if (PRIV (location_stack
))
699 free (PRIV (location_stack
));
700 PRIV (location_stack
) = 0;
703 for (i
= 0; i
< VMS_SECTION_COUNT
; i
++)
705 es
= PRIV (vms_section_table
)[i
];
712 PRIV (vms_section_table
)[i
] = NULL
;
715 free (abfd
->tdata
.any
);
716 abfd
->tdata
.any
= NULL
;
721 /* Ask the BFD to free all cached information. */
723 vms_bfd_free_cached_info (abfd
)
724 bfd
*abfd ATTRIBUTE_UNUSED
;
727 vms_debug (1, "vms_bfd_free_cached_info(%p)\n", abfd
);
732 /* Called when a new section is created. */
735 vms_new_section_hook (abfd
, section
)
739 /* Count hasn't been incremented yet. */
740 unsigned int section_count
= abfd
->section_count
+ 1;
743 vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
744 abfd
, section
->index
, section
->name
, section_count
);
746 bfd_set_section_alignment (abfd
, section
, 4);
748 if (section_count
> PRIV (section_count
))
750 bfd_size_type amt
= section_count
;
751 amt
*= sizeof (asection
*);
752 PRIV (sections
) = (asection
**) bfd_realloc (PRIV (sections
), amt
);
753 if (PRIV (sections
) == 0)
755 PRIV (section_count
) = section_count
;
758 vms_debug (6, "section_count: %d\n", PRIV (section_count
));
760 PRIV (sections
)[section
->index
] = section
;
762 vms_debug (7, "%d: %s\n", section
->index
, section
->name
);
768 /* Read the contents of a section.
769 buf points to a buffer of buf_size bytes to be filled with
770 section data (starting at offset into section) */
773 vms_get_section_contents (abfd
, section
, buf
, offset
, buf_size
)
774 bfd
*abfd ATTRIBUTE_UNUSED
;
775 asection
*section ATTRIBUTE_UNUSED
;
776 PTR buf ATTRIBUTE_UNUSED
;
777 file_ptr offset ATTRIBUTE_UNUSED
;
778 bfd_size_type buf_size ATTRIBUTE_UNUSED
;
781 vms_debug (1, "vms_get_section_contents(%p, %s, %p, off %ld, size %d)\n",
782 abfd
, section
->name
, buf
, offset
, (int)buf_size
);
785 /* shouldn't be called, since all sections are IN_MEMORY */
790 /* Read the contents of a section.
791 buf points to a buffer of buf_size bytes to be filled with
792 section data (starting at offset into section) */
795 vms_get_section_contents_in_window (abfd
, section
, w
, offset
, count
)
796 bfd
*abfd ATTRIBUTE_UNUSED
;
797 asection
*section ATTRIBUTE_UNUSED
;
798 bfd_window
*w ATTRIBUTE_UNUSED
;
799 file_ptr offset ATTRIBUTE_UNUSED
;
800 bfd_size_type count ATTRIBUTE_UNUSED
;
803 vms_debug (1, "vms_get_section_contents_in_window(%p, %s, %p, off %ld, count %d)\n",
804 abfd
, section
->name
, w
, offset
, (int)count
);
807 /* shouldn't be called, since all sections are IN_MEMORY */
812 /*-- Part 4.2, copy private data --------------------------------------------*/
814 /* Called to copy BFD general private data from one object file
818 vms_bfd_copy_private_bfd_data (src
, dest
)
819 bfd
*src ATTRIBUTE_UNUSED
;
820 bfd
*dest ATTRIBUTE_UNUSED
;
823 vms_debug (1, "vms_bfd_copy_private_bfd_data(%p, %p)\n", src
, dest
);
828 /* Merge private BFD information from the BFD @var{ibfd} to the
829 the output file BFD @var{obfd} when linking. Return <<true>>
830 on success, <<false>> on error. Possible error returns are:
832 o <<bfd_error_no_memory>> -
833 Not enough memory exists to create private data for @var{obfd}. */
836 vms_bfd_merge_private_bfd_data (ibfd
, obfd
)
837 bfd
*ibfd ATTRIBUTE_UNUSED
;
838 bfd
*obfd ATTRIBUTE_UNUSED
;
841 vms_debug (1,"vms_bfd_merge_private_bfd_data(%p, %p)\n", ibfd
, obfd
);
846 /* Set private BFD flag information in the BFD @var{abfd}.
847 Return <<true>> on success, <<false>> on error. Possible error
850 o <<bfd_error_no_memory>> -
851 Not enough memory exists to create private data for @var{obfd}. */
854 vms_bfd_set_private_flags (abfd
, flags
)
855 bfd
*abfd ATTRIBUTE_UNUSED
;
856 flagword flags ATTRIBUTE_UNUSED
;
859 vms_debug (1,"vms_bfd_set_private_flags(%p, %lx)\n", abfd
, (long)flags
);
864 /* Called to copy BFD private section data from one object file
868 vms_bfd_copy_private_section_data (srcbfd
, srcsec
, dstbfd
, dstsec
)
869 bfd
*srcbfd ATTRIBUTE_UNUSED
;
870 asection
*srcsec ATTRIBUTE_UNUSED
;
871 bfd
*dstbfd ATTRIBUTE_UNUSED
;
872 asection
*dstsec ATTRIBUTE_UNUSED
;
875 vms_debug (1, "vms_bfd_copy_private_section_data(%p, %s, %p, %s)\n",
876 srcbfd
, srcsec
->name
, dstbfd
, dstsec
->name
);
881 /* Called to copy BFD private symbol data from one object file
885 vms_bfd_copy_private_symbol_data (ibfd
, isym
, obfd
, osym
)
886 bfd
*ibfd ATTRIBUTE_UNUSED
;
887 asymbol
*isym ATTRIBUTE_UNUSED
;
888 bfd
*obfd ATTRIBUTE_UNUSED
;
889 asymbol
*osym ATTRIBUTE_UNUSED
;
892 vms_debug (1, "vms_bfd_copy_private_symbol_data(%p, %s, %p, %s)\n",
893 ibfd
, isym
->name
, obfd
, osym
->name
);
898 /*-- Part 4.3, core file ----------------------------------------------------*/
900 /* Return a read-only string explaining which program was running
901 when it failed and produced the core file abfd. */
904 vms_core_file_failing_command (abfd
)
905 bfd
*abfd ATTRIBUTE_UNUSED
;
908 vms_debug (1, "vms_core_file_failing_command(%p)\n", abfd
);
913 /* Returns the signal number which caused the core dump which
914 generated the file the BFD abfd is attached to. */
917 vms_core_file_failing_signal (abfd
)
918 bfd
*abfd ATTRIBUTE_UNUSED
;
921 vms_debug (1, "vms_core_file_failing_signal(%p)\n", abfd
);
926 /* Return true if the core file attached to core_bfd was generated
927 by a run of the executable file attached to exec_bfd, false otherwise. */
930 vms_core_file_matches_executable_p (abfd
, bbfd
)
931 bfd
*abfd ATTRIBUTE_UNUSED
;
932 bfd
*bbfd ATTRIBUTE_UNUSED
;
935 vms_debug (1, "vms_core_file_matches_executable_p(%p, %p)\n", abfd
, bbfd
);
940 /*-- Part 4.4, archive ------------------------------------------------------*/
942 /* ??? do something with an archive map.
943 Return false on error, true otherwise. */
946 vms_slurp_armap (abfd
)
947 bfd
*abfd ATTRIBUTE_UNUSED
;
950 vms_debug (1, "vms_slurp_armap(%p)\n", abfd
);
955 /* ??? do something with an extended name table.
956 Return false on error, true otherwise. */
959 vms_slurp_extended_name_table (abfd
)
960 bfd
*abfd ATTRIBUTE_UNUSED
;
963 vms_debug (1, "vms_slurp_extended_name_table(%p)\n", abfd
);
968 /* ??? do something with an extended name table.
969 Return false on error, true otherwise. */
972 vms_construct_extended_name_table (abfd
, tabloc
, tablen
, name
)
973 bfd
*abfd ATTRIBUTE_UNUSED
;
974 char **tabloc ATTRIBUTE_UNUSED
;
975 bfd_size_type
*tablen ATTRIBUTE_UNUSED
;
976 const char **name ATTRIBUTE_UNUSED
;
979 vms_debug (1, "vms_construct_extended_name_table(%p)\n", abfd
);
984 /* Truncate the name of an archive to match system-dependent restrictions */
987 vms_truncate_arname (abfd
, pathname
, arhdr
)
988 bfd
*abfd ATTRIBUTE_UNUSED
;
989 const char *pathname ATTRIBUTE_UNUSED
;
990 char *arhdr ATTRIBUTE_UNUSED
;
993 vms_debug (1, "vms_truncate_arname(%p, %s, %s)\n", abfd
, pathname
, arhdr
);
998 /* ??? write archive map */
1001 vms_write_armap (arch
, elength
, map
, orl_count
, stridx
)
1002 bfd
*arch ATTRIBUTE_UNUSED
;
1003 unsigned int elength ATTRIBUTE_UNUSED
;
1004 struct orl
*map ATTRIBUTE_UNUSED
;
1005 unsigned int orl_count ATTRIBUTE_UNUSED
;
1006 int stridx ATTRIBUTE_UNUSED
;
1009 vms_debug (1, "vms_write_armap(%p, %d, %p, %d %d)\n",
1010 arch
, elength
, map
, orl_count
, stridx
);
1015 /* Read archive header ??? */
1018 vms_read_ar_hdr (abfd
)
1019 bfd
* abfd ATTRIBUTE_UNUSED
;
1022 vms_debug (1, "vms_read_ar_hdr(%p)\n", abfd
);
1027 /* Provided a BFD, @var{archive}, containing an archive and NULL, open
1028 an input BFD on the first contained element and returns that.
1029 Subsequent calls should pass the archive and the previous return value
1030 to return a created BFD to the next contained element.
1031 NULL is returned when there are no more. */
1034 vms_openr_next_archived_file (arch
, prev
)
1035 bfd
*arch ATTRIBUTE_UNUSED
;
1036 bfd
*prev ATTRIBUTE_UNUSED
;
1039 vms_debug (1, "vms_openr_next_archived_file(%p, %p)\n", arch
, prev
);
1044 /* Return the BFD which is referenced by the symbol in ABFD indexed by
1045 INDEX. INDEX should have been returned by bfd_get_next_mapent. */
1048 vms_get_elt_at_index (abfd
, index
)
1053 vms_debug (1, "vms_get_elt_at_index(%p, %p)\n", abfd
, index
);
1055 return _bfd_generic_get_elt_at_index(abfd
, index
);
1059 -> bfd_generic_stat_arch_elt */
1062 vms_generic_stat_arch_elt (abfd
, st
)
1067 vms_debug (1, "vms_generic_stat_arch_elt(%p, %p)\n", abfd
, st
);
1069 return bfd_generic_stat_arch_elt (abfd
, st
);
1072 /* This is a new function in bfd 2.5 */
1075 vms_update_armap_timestamp (abfd
)
1076 bfd
*abfd ATTRIBUTE_UNUSED
;
1079 vms_debug (1, "vms_update_armap_timestamp(%p)\n", abfd
);
1084 /*-- Part 4.5, symbols --------------------------------------------------------*/
1086 /* Return the number of bytes required to store a vector of pointers
1087 to asymbols for all the symbols in the BFD abfd, including a
1088 terminal NULL pointer. If there are no symbols in the BFD,
1089 then return 0. If an error occurs, return -1. */
1092 vms_get_symtab_upper_bound (abfd
)
1096 vms_debug (1, "vms_get_symtab_upper_bound(%p), %d symbols\n", abfd
, PRIV (gsd_sym_count
));
1098 return (PRIV (gsd_sym_count
)+1) * sizeof (asymbol
*);
1101 /* Copy symbols from hash table to symbol vector
1103 called from bfd_hash_traverse in vms_get_symtab
1104 init counter to 0 if entry == 0 */
1107 copy_symbols (entry
, arg
)
1108 struct bfd_hash_entry
*entry
;
1111 bfd
*abfd
= (bfd
*) arg
;
1113 if (entry
== NULL
) /* init counter */
1115 else /* fill vector, inc counter */
1116 PRIV (symcache
)[PRIV (symnum
)++] = ((vms_symbol_entry
*)entry
)->symbol
;
1121 /* Read the symbols from the BFD abfd, and fills in the vector
1122 location with pointers to the symbols and a trailing NULL.
1124 return # of symbols read */
1127 vms_get_symtab (abfd
, symbols
)
1132 vms_debug (1, "vms_get_symtab(%p, <ret>)\n", abfd
);
1136 (void)copy_symbols((struct bfd_hash_entry
*)0, abfd
);
1138 /* traverse table and fill symbols vector */
1140 PRIV (symcache
) = symbols
;
1141 bfd_hash_traverse(PRIV (vms_symbol_table
), copy_symbols
, (PTR
)abfd
);
1143 symbols
[PRIV (gsd_sym_count
)] = NULL
;
1145 return PRIV (gsd_sym_count
);
1148 /* Print symbol to file according to how. how is one of
1149 bfd_print_symbol_name just print the name
1150 bfd_print_symbol_more print more (???)
1151 bfd_print_symbol_all print all we know, which is not much right now :-) */
1154 vms_print_symbol (abfd
, file
, symbol
, how
)
1158 bfd_print_symbol_type how
;
1161 vms_debug (1, "vms_print_symbol(%p, %p, %p, %d)\n", abfd
, file
, symbol
, how
);
1166 case bfd_print_symbol_name
:
1167 case bfd_print_symbol_more
:
1168 fprintf ((FILE *)file
," %s", symbol
->name
);
1171 case bfd_print_symbol_all
:
1173 const char *section_name
= symbol
->section
->name
;
1175 bfd_print_symbol_vandf (abfd
, (PTR
)file
, symbol
);
1177 fprintf ((FILE *)file
," %-8s %s", section_name
, symbol
->name
);
1184 /* Return information about symbol in ret.
1186 fill type, value and name
1189 B bss segment symbol
1191 D data segment symbol
1193 t a static function symbol
1194 T text segment symbol
1199 vms_get_symbol_info (abfd
, symbol
, ret
)
1200 bfd
*abfd ATTRIBUTE_UNUSED
;
1207 vms_debug (1, "vms_get_symbol_info(%p, %p, %p)\n", abfd
, symbol
, ret
);
1210 sec
= symbol
->section
;
1215 if (bfd_is_com_section (sec
))
1217 else if (bfd_is_abs_section (sec
))
1219 else if (bfd_is_und_section (sec
))
1221 else if (bfd_is_ind_section (sec
))
1223 else if (bfd_get_section_flags (abfd
, sec
) & SEC_CODE
)
1225 else if (bfd_get_section_flags (abfd
, sec
) & SEC_DATA
)
1227 else if (bfd_get_section_flags (abfd
, sec
) & SEC_ALLOC
)
1232 if (ret
->type
!= 'U')
1233 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
1236 ret
->name
= symbol
->name
;
1241 /* Return true if the given symbol sym in the BFD abfd is
1242 a compiler generated local label, else return false. */
1245 vms_bfd_is_local_label_name (abfd
, name
)
1246 bfd
*abfd ATTRIBUTE_UNUSED
;
1250 vms_debug (1, "vms_bfd_is_local_label_name(%p, %s)\n", abfd
, name
);
1252 return name
[0] == '$';
1255 /* Get source line number for symbol */
1258 vms_get_lineno (abfd
, symbol
)
1259 bfd
*abfd ATTRIBUTE_UNUSED
;
1260 asymbol
*symbol ATTRIBUTE_UNUSED
;
1263 vms_debug (1, "vms_get_lineno(%p, %p)\n", abfd
, symbol
);
1268 /* Provided a BFD, a section and an offset into the section, calculate and
1269 return the name of the source file and the line nearest to the wanted
1273 vms_find_nearest_line (abfd
, section
, symbols
, offset
, file
, func
, line
)
1274 bfd
*abfd ATTRIBUTE_UNUSED
;
1275 asection
*section ATTRIBUTE_UNUSED
;
1276 asymbol
**symbols ATTRIBUTE_UNUSED
;
1277 bfd_vma offset ATTRIBUTE_UNUSED
;
1278 const char **file ATTRIBUTE_UNUSED
;
1279 const char **func ATTRIBUTE_UNUSED
;
1280 unsigned int *line ATTRIBUTE_UNUSED
;
1283 vms_debug (1, "vms_find_nearest_line(%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
1284 abfd
, section
->name
, symbols
, (long int)offset
);
1289 /* Back-door to allow format-aware applications to create debug symbols
1290 while using BFD for everything else. Currently used by the assembler
1291 when creating COFF files. */
1294 vms_bfd_make_debug_symbol (abfd
, ptr
, size
)
1295 bfd
*abfd ATTRIBUTE_UNUSED
;
1296 void *ptr ATTRIBUTE_UNUSED
;
1297 unsigned long size ATTRIBUTE_UNUSED
;
1300 vms_debug (1, "vms_bfd_make_debug_symbol(%p, %p, %ld)\n", abfd
, ptr
, size
);
1305 /* Read minisymbols. For minisymbols, we use the unmodified a.out
1306 symbols. The minisymbol_to_symbol function translates these into
1307 BFD asymbol structures. */
1310 vms_read_minisymbols (abfd
, dynamic
, minisymsp
, sizep
)
1314 unsigned int *sizep
;
1317 vms_debug (1, "vms_read_minisymbols(%p, %d, %p, %d)\n", abfd
, dynamic
, minisymsp
, *sizep
);
1319 return _bfd_generic_read_minisymbols (abfd
, dynamic
, minisymsp
, sizep
);
1322 /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1323 unmodified a.out symbol. The SYM argument is a structure returned
1324 by bfd_make_empty_symbol, which we fill in here. */
1327 vms_minisymbol_to_symbol (abfd
, dynamic
, minisym
, sym
)
1334 vms_debug (1, "vms_minisymbol_to_symbol(%p, %d, %p, %p)\n", abfd
, dynamic
, minisym
, sym
);
1336 return _bfd_generic_minisymbol_to_symbol (abfd
, dynamic
, minisym
, sym
);
1339 /*-- Part 4.6, relocations --------------------------------------------------*/
1341 /* Return the number of bytes required to store the relocation information
1342 associated with section sect attached to bfd abfd.
1343 If an error occurs, return -1. */
1346 vms_get_reloc_upper_bound (abfd
, section
)
1347 bfd
*abfd ATTRIBUTE_UNUSED
;
1348 asection
*section ATTRIBUTE_UNUSED
;
1351 vms_debug (1, "vms_get_reloc_upper_bound(%p, %s)\n", abfd
, section
->name
);
1356 /* Call the back end associated with the open BFD abfd and translate the
1357 external form of the relocation information attached to sec into the
1358 internal canonical form. Place the table into memory at loc, which has
1359 been preallocated, usually by a call to bfd_get_reloc_upper_bound.
1360 Returns the number of relocs, or -1 on error. */
1363 vms_canonicalize_reloc (abfd
, section
, location
, symbols
)
1364 bfd
*abfd ATTRIBUTE_UNUSED
;
1365 asection
*section ATTRIBUTE_UNUSED
;
1366 arelent
**location ATTRIBUTE_UNUSED
;
1367 asymbol
**symbols ATTRIBUTE_UNUSED
;
1370 vms_debug (1, "vms_canonicalize_reloc(%p, %s, <ret>, <ret>)\n", abfd
, section
->name
);
1375 /*---------------------------------------------------------------------------*/
1376 /* this is just copied from ecoff-alpha, needs to be fixed probably */
1378 /* How to process the various reloc types. */
1380 static bfd_reloc_status_type
1381 reloc_nil (abfd
, reloc
, sym
, data
, sec
, output_bfd
, error_message
)
1382 bfd
*abfd ATTRIBUTE_UNUSED
;
1383 arelent
*reloc ATTRIBUTE_UNUSED
;
1384 asymbol
*sym ATTRIBUTE_UNUSED
;
1385 PTR data ATTRIBUTE_UNUSED
;
1386 asection
*sec ATTRIBUTE_UNUSED
;
1387 bfd
*output_bfd ATTRIBUTE_UNUSED
;
1388 char **error_message ATTRIBUTE_UNUSED
;
1391 vms_debug (1, "reloc_nil(abfd %p, output_bfd %p)\n", abfd
, output_bfd
);
1392 vms_debug (2, "In section %s, symbol %s\n",
1393 sec
->name
, sym
->name
);
1394 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1395 reloc
->sym_ptr_ptr
[0]->name
,
1396 (unsigned long)reloc
->address
,
1397 (unsigned long)reloc
->addend
, reloc
->howto
->name
);
1398 vms_debug (2, "data at %p\n", data
);
1399 /* _bfd_hexdump (2, data, bfd_get_reloc_size(reloc->howto),0); */
1402 return bfd_reloc_ok
;
1405 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1406 from smaller values. Start with zero, widen, *then* decrement. */
1407 #define MINUS_ONE (((bfd_vma)0) - 1)
1409 static reloc_howto_type alpha_howto_table
[] =
1411 HOWTO (ALPHA_R_IGNORE
, /* type */
1413 0, /* size (0 = byte, 1 = short, 2 = long) */
1415 true, /* pc_relative */
1417 complain_overflow_dont
, /* complain_on_overflow */
1418 reloc_nil
, /* special_function */
1419 "IGNORE", /* name */
1420 true, /* partial_inplace */
1423 true), /* pcrel_offset */
1425 /* A 64 bit reference to a symbol. */
1426 HOWTO (ALPHA_R_REFQUAD
, /* type */
1428 4, /* size (0 = byte, 1 = short, 2 = long) */
1430 false, /* pc_relative */
1432 complain_overflow_bitfield
, /* complain_on_overflow */
1433 reloc_nil
, /* special_function */
1434 "REFQUAD", /* name */
1435 true, /* partial_inplace */
1436 MINUS_ONE
, /* src_mask */
1437 MINUS_ONE
, /* dst_mask */
1438 false), /* pcrel_offset */
1440 /* A 21 bit branch. The native assembler generates these for
1441 branches within the text segment, and also fills in the PC
1442 relative offset in the instruction. */
1443 HOWTO (ALPHA_R_BRADDR
, /* type */
1445 2, /* size (0 = byte, 1 = short, 2 = long) */
1447 true, /* pc_relative */
1449 complain_overflow_signed
, /* complain_on_overflow */
1450 reloc_nil
, /* special_function */
1451 "BRADDR", /* name */
1452 true, /* partial_inplace */
1453 0x1fffff, /* src_mask */
1454 0x1fffff, /* dst_mask */
1455 false), /* pcrel_offset */
1457 /* A hint for a jump to a register. */
1458 HOWTO (ALPHA_R_HINT
, /* type */
1460 1, /* size (0 = byte, 1 = short, 2 = long) */
1462 true, /* pc_relative */
1464 complain_overflow_dont
, /* complain_on_overflow */
1465 reloc_nil
, /* special_function */
1467 true, /* partial_inplace */
1468 0x3fff, /* src_mask */
1469 0x3fff, /* dst_mask */
1470 false), /* pcrel_offset */
1472 /* 16 bit PC relative offset. */
1473 HOWTO (ALPHA_R_SREL16
, /* type */
1475 1, /* size (0 = byte, 1 = short, 2 = long) */
1477 true, /* pc_relative */
1479 complain_overflow_signed
, /* complain_on_overflow */
1480 reloc_nil
, /* special_function */
1481 "SREL16", /* name */
1482 true, /* partial_inplace */
1483 0xffff, /* src_mask */
1484 0xffff, /* dst_mask */
1485 false), /* pcrel_offset */
1487 /* 32 bit PC relative offset. */
1488 HOWTO (ALPHA_R_SREL32
, /* type */
1490 2, /* size (0 = byte, 1 = short, 2 = long) */
1492 true, /* pc_relative */
1494 complain_overflow_signed
, /* complain_on_overflow */
1495 reloc_nil
, /* special_function */
1496 "SREL32", /* name */
1497 true, /* partial_inplace */
1498 0xffffffff, /* src_mask */
1499 0xffffffff, /* dst_mask */
1500 false), /* pcrel_offset */
1502 /* A 64 bit PC relative offset. */
1503 HOWTO (ALPHA_R_SREL64
, /* type */
1505 4, /* size (0 = byte, 1 = short, 2 = long) */
1507 true, /* pc_relative */
1509 complain_overflow_signed
, /* complain_on_overflow */
1510 reloc_nil
, /* special_function */
1511 "SREL64", /* name */
1512 true, /* partial_inplace */
1513 MINUS_ONE
, /* src_mask */
1514 MINUS_ONE
, /* dst_mask */
1515 false), /* pcrel_offset */
1517 /* Push a value on the reloc evaluation stack. */
1518 HOWTO (ALPHA_R_OP_PUSH
, /* type */
1520 0, /* size (0 = byte, 1 = short, 2 = long) */
1522 false, /* pc_relative */
1524 complain_overflow_dont
, /* complain_on_overflow */
1525 reloc_nil
, /* special_function */
1526 "OP_PUSH", /* name */
1527 false, /* partial_inplace */
1530 false), /* pcrel_offset */
1532 /* Store the value from the stack at the given address. Store it in
1533 a bitfield of size r_size starting at bit position r_offset. */
1534 HOWTO (ALPHA_R_OP_STORE
, /* type */
1536 4, /* size (0 = byte, 1 = short, 2 = long) */
1538 false, /* pc_relative */
1540 complain_overflow_dont
, /* complain_on_overflow */
1541 reloc_nil
, /* special_function */
1542 "OP_STORE", /* name */
1543 false, /* partial_inplace */
1545 MINUS_ONE
, /* dst_mask */
1546 false), /* pcrel_offset */
1548 /* Subtract the reloc address from the value on the top of the
1549 relocation stack. */
1550 HOWTO (ALPHA_R_OP_PSUB
, /* type */
1552 0, /* size (0 = byte, 1 = short, 2 = long) */
1554 false, /* pc_relative */
1556 complain_overflow_dont
, /* complain_on_overflow */
1557 reloc_nil
, /* special_function */
1558 "OP_PSUB", /* name */
1559 false, /* partial_inplace */
1562 false), /* pcrel_offset */
1564 /* Shift the value on the top of the relocation stack right by the
1566 HOWTO (ALPHA_R_OP_PRSHIFT
, /* type */
1568 0, /* size (0 = byte, 1 = short, 2 = long) */
1570 false, /* pc_relative */
1572 complain_overflow_dont
, /* complain_on_overflow */
1573 reloc_nil
, /* special_function */
1574 "OP_PRSHIFT", /* name */
1575 false, /* partial_inplace */
1578 false), /* pcrel_offset */
1580 /* Hack. Linkage is done by linker. */
1581 HOWTO (ALPHA_R_LINKAGE
, /* type */
1583 8, /* size (0 = byte, 1 = short, 2 = long) */
1585 false, /* pc_relative */
1587 complain_overflow_dont
, /* complain_on_overflow */
1588 reloc_nil
, /* special_function */
1589 "LINKAGE", /* name */
1590 false, /* partial_inplace */
1593 false), /* pcrel_offset */
1595 /* A 32 bit reference to a symbol. */
1596 HOWTO (ALPHA_R_REFLONG
, /* type */
1598 2, /* size (0 = byte, 1 = short, 2 = long) */
1600 false, /* pc_relative */
1602 complain_overflow_bitfield
, /* complain_on_overflow */
1603 reloc_nil
, /* special_function */
1604 "REFLONG", /* name */
1605 true, /* partial_inplace */
1606 0xffffffff, /* src_mask */
1607 0xffffffff, /* dst_mask */
1608 false), /* pcrel_offset */
1610 /* A 64 bit reference to a procedure, written as 32 bit value. */
1611 HOWTO (ALPHA_R_CODEADDR
, /* type */
1613 4, /* size (0 = byte, 1 = short, 2 = long) */
1615 false, /* pc_relative */
1617 complain_overflow_signed
,/* complain_on_overflow */
1618 reloc_nil
, /* special_function */
1619 "CODEADDR", /* name */
1620 false, /* partial_inplace */
1621 0xffffffff, /* src_mask */
1622 0xffffffff, /* dst_mask */
1623 false), /* pcrel_offset */
1627 /* Return a pointer to a howto structure which, when invoked, will perform
1628 the relocation code on data from the architecture noted. */
1630 static const struct reloc_howto_struct
*
1631 vms_bfd_reloc_type_lookup (abfd
, code
)
1632 bfd
*abfd ATTRIBUTE_UNUSED
;
1633 bfd_reloc_code_real_type code
;
1638 vms_debug (1, "vms_bfd_reloc_type_lookup(%p, %d)\t", abfd
, code
);
1643 case BFD_RELOC_16
: alpha_type
= ALPHA_R_SREL16
; break;
1644 case BFD_RELOC_32
: alpha_type
= ALPHA_R_REFLONG
; break;
1645 case BFD_RELOC_64
: alpha_type
= ALPHA_R_REFQUAD
; break;
1646 case BFD_RELOC_CTOR
: alpha_type
= ALPHA_R_REFQUAD
; break;
1647 case BFD_RELOC_23_PCREL_S2
: alpha_type
= ALPHA_R_BRADDR
; break;
1648 case BFD_RELOC_ALPHA_HINT
: alpha_type
= ALPHA_R_HINT
; break;
1649 case BFD_RELOC_16_PCREL
: alpha_type
= ALPHA_R_SREL16
; break;
1650 case BFD_RELOC_32_PCREL
: alpha_type
= ALPHA_R_SREL32
; break;
1651 case BFD_RELOC_64_PCREL
: alpha_type
= ALPHA_R_SREL64
; break;
1652 case BFD_RELOC_ALPHA_LINKAGE
: alpha_type
= ALPHA_R_LINKAGE
; break;
1653 case BFD_RELOC_ALPHA_CODEADDR
: alpha_type
= ALPHA_R_CODEADDR
; break;
1655 (*_bfd_error_handler
) ("reloc (%d) is *UNKNOWN*", code
);
1656 return (const struct reloc_howto_struct
*) NULL
;
1659 vms_debug (2, "reloc is %s\n", alpha_howto_table
[alpha_type
].name
);
1661 return &alpha_howto_table
[alpha_type
];
1664 /*-- Part 4.7, writing an object file ---------------------------------------*/
1666 /* Set the architecture and machine type in BFD abfd to arch and mach.
1667 Find the correct pointer to a structure and insert it into the arch_info
1671 vms_set_arch_mach (abfd
, arch
, mach
)
1673 enum bfd_architecture arch ATTRIBUTE_UNUSED
;
1674 unsigned long mach ATTRIBUTE_UNUSED
;
1677 vms_debug (1, "vms_set_arch_mach(%p, %d, %ld)\n", abfd
, arch
, mach
);
1679 abfd
->arch_info
= bfd_scan_arch("alpha");
1684 /* Sets the contents of the section section in BFD abfd to the data starting
1685 in memory at data. The data is written to the output section starting at
1686 offset offset for count bytes.
1688 Normally true is returned, else false. Possible error returns are:
1689 o bfd_error_no_contents - The output section does not have the
1690 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1691 o and some more too */
1694 vms_set_section_contents (abfd
, section
, location
, offset
, count
)
1699 bfd_size_type count
;
1702 vms_debug (1, "vms_set_section_contents(%p, sec %s, loc %p, off %ld, count %d)\n",
1703 abfd
, section
->name
, location
, (long int)offset
, (int)count
);
1704 vms_debug (2, "secraw %d, seccooked %d\n", (int)section
->_raw_size
, (int)section
->_cooked_size
);
1706 return _bfd_save_vms_section(abfd
, section
, location
, offset
, count
);
1709 /*-- Part 4.8, linker -------------------------------------------------------*/
1711 /* Get the size of the section headers. */
1714 vms_sizeof_headers (abfd
, reloc
)
1715 bfd
*abfd ATTRIBUTE_UNUSED
;
1716 boolean reloc ATTRIBUTE_UNUSED
;
1719 vms_debug (1, "vms_sizeof_headers(%p, %s)\n", abfd
, (reloc
)?"True":"False");
1724 /* Provides default handling of relocation effort for back ends
1725 which can't be bothered to do it efficiently. */
1728 vms_bfd_get_relocated_section_contents (abfd
, link_info
, link_order
, data
,
1729 relocateable
, symbols
)
1730 bfd
*abfd ATTRIBUTE_UNUSED
;
1731 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1732 struct bfd_link_order
*link_order ATTRIBUTE_UNUSED
;
1733 bfd_byte
*data ATTRIBUTE_UNUSED
;
1734 boolean relocateable ATTRIBUTE_UNUSED
;
1735 asymbol
**symbols ATTRIBUTE_UNUSED
;
1738 vms_debug (1, "vms_bfd_get_relocated_section_contents(%p, %p, %p, %p, %s, %p)\n",
1739 abfd
, link_info
, link_order
, data
, (relocateable
)?"True":"False", symbols
);
1747 vms_bfd_relax_section (abfd
, section
, link_info
, again
)
1748 bfd
*abfd ATTRIBUTE_UNUSED
;
1749 asection
*section ATTRIBUTE_UNUSED
;
1750 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1751 boolean
*again ATTRIBUTE_UNUSED
;
1754 vms_debug (1, "vms_bfd_relax_section(%p, %s, %p, <ret>)\n",
1755 abfd
, section
->name
, link_info
);
1761 vms_bfd_gc_sections (abfd
, link_info
)
1762 bfd
*abfd ATTRIBUTE_UNUSED
;
1763 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1766 vms_debug (1, "vms_bfd_gc_sections(%p, %p)\n", abfd
, link_info
);
1772 vms_bfd_merge_sections (abfd
, link_info
)
1773 bfd
*abfd ATTRIBUTE_UNUSED
;
1774 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1777 vms_debug (1, "vms_bfd_merge_sections(%p, %p)\n", abfd
, link_info
);
1782 /* Create a hash table for the linker. Different backends store
1783 different information in this table. */
1785 static struct bfd_link_hash_table
*
1786 vms_bfd_link_hash_table_create (abfd
)
1787 bfd
*abfd ATTRIBUTE_UNUSED
;
1790 vms_debug (1, "vms_bfd_link_hash_table_create(%p)\n", abfd
);
1795 /* Free a linker hash table. */
1798 vms_bfd_link_hash_table_free (hash
)
1799 struct bfd_link_hash_table
*hash ATTRIBUTE_UNUSED
;
1802 vms_debug (1, "vms_bfd_link_hash_table_free(%p)\n", abfd
);
1806 /* Add symbols from this object file into the hash table. */
1809 vms_bfd_link_add_symbols (abfd
, link_info
)
1810 bfd
*abfd ATTRIBUTE_UNUSED
;
1811 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1814 vms_debug (1, "vms_bfd_link_add_symbols(%p, %p)\n", abfd
, link_info
);
1819 /* Do a link based on the link_order structures attached to each
1820 section of the BFD. */
1823 vms_bfd_final_link (abfd
, link_info
)
1824 bfd
*abfd ATTRIBUTE_UNUSED
;
1825 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
1828 vms_debug (1, "vms_bfd_final_link(%p, %p)\n", abfd
, link_info
);
1833 /* Should this section be split up into smaller pieces during linking. */
1836 vms_bfd_link_split_section (abfd
, section
)
1837 bfd
*abfd ATTRIBUTE_UNUSED
;
1838 asection
*section ATTRIBUTE_UNUSED
;
1841 vms_debug (1, "vms_bfd_link_split_section(%p, %s)\n", abfd
, section
->name
);
1846 /*-- Part 4.9, dynamic symbols and relocations ------------------------------*/
1848 /* Get the amount of memory required to hold the dynamic symbols. */
1851 vms_get_dynamic_symtab_upper_bound (abfd
)
1852 bfd
*abfd ATTRIBUTE_UNUSED
;
1855 vms_debug (1, "vms_get_dynamic_symtab_upper_bound(%p)\n", abfd
);
1861 vms_bfd_print_private_bfd_data (abfd
, file
)
1862 bfd
*abfd ATTRIBUTE_UNUSED
;
1863 void *file ATTRIBUTE_UNUSED
;
1866 vms_debug (1, "vms_bfd_print_private_bfd_data(%p)\n", abfd
);
1871 /* Read in the dynamic symbols. */
1874 vms_canonicalize_dynamic_symtab (abfd
, symbols
)
1875 bfd
*abfd ATTRIBUTE_UNUSED
;
1876 asymbol
**symbols ATTRIBUTE_UNUSED
;
1879 vms_debug (1, "vms_canonicalize_dynamic_symtab(%p, <ret>)\n", abfd
);
1884 /* Get the amount of memory required to hold the dynamic relocs. */
1887 vms_get_dynamic_reloc_upper_bound (abfd
)
1888 bfd
*abfd ATTRIBUTE_UNUSED
;
1891 vms_debug (1, "vms_get_dynamic_reloc_upper_bound(%p)\n", abfd
);
1896 /* Read in the dynamic relocs. */
1899 vms_canonicalize_dynamic_reloc (abfd
, arel
, symbols
)
1900 bfd
*abfd ATTRIBUTE_UNUSED
;
1901 arelent
**arel ATTRIBUTE_UNUSED
;
1902 asymbol
**symbols ATTRIBUTE_UNUSED
;
1905 vms_debug (1, "vms_canonicalize_dynamic_reloc(%p)\n", abfd
);