daily update
[binutils.git] / bfd / vms.c
blob8111d4955e2de5a99ea957b4d71627a3e97f5927
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, 2003, 2004, 2005,
4 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6 Main file.
8 Written by Klaus K"ampf (kkaempf@rmi.de)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 MA 02110-1301, USA. */
25 #ifdef VMS
26 #include <rms.h>
27 #include <starlet.h>
28 #define RME$C_SETRFM 0x00000001
29 #include <unistd.h>
30 #endif
32 #include "sysdep.h"
33 #include "bfd.h"
34 #include "bfdlink.h"
35 #include "libbfd.h"
37 #include "vms.h"
39 static bfd_boolean vms_initialize (bfd *);
40 static bfd_boolean fill_section_ptr (struct bfd_hash_entry *, PTR);
41 static bfd_boolean vms_fixup_sections (bfd *);
42 static bfd_boolean copy_symbols (struct bfd_hash_entry *, PTR);
43 static bfd_reloc_status_type reloc_nil (bfd *, arelent *, asymbol *, PTR,
44 asection *, bfd *, char **);
45 static int vms_slurp_module (bfd *abfd);
46 static int vms_slurp_image (bfd *abfd);
47 static const struct bfd_target *vms_object_p (bfd *abfd);
48 static const struct bfd_target *vms_archive_p (bfd *abfd);
49 static bfd_boolean vms_mkobject (bfd *abfd);
50 static bfd_boolean vms_write_object_contents (bfd *abfd);
51 static void free_reloc_stream (bfd *abfd, asection *section, void *data);
52 static bfd_boolean vms_close_and_cleanup (bfd *abfd);
53 static bfd_boolean vms_bfd_free_cached_info (bfd *abfd);
54 static bfd_boolean vms_new_section_hook (bfd *abfd, asection *section);
55 static bfd_boolean vms_get_section_contents
56 (bfd *abfd, asection *section, PTR x1, file_ptr x2, bfd_size_type x3);
57 static bfd_boolean vms_get_section_contents_in_window
58 (bfd *abfd, asection *section, bfd_window *w, file_ptr offset,
59 bfd_size_type count);
60 static bfd_boolean vms_bfd_copy_private_bfd_data (bfd *src, bfd *dest);
61 static bfd_boolean vms_bfd_copy_private_section_data
62 (bfd *srcbfd, asection *srcsec, bfd *dstbfd, asection *dstsec);
63 static bfd_boolean vms_bfd_copy_private_symbol_data
64 (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
65 static bfd_boolean vms_bfd_print_private_bfd_data (bfd *abfd, void *file);
66 static char *vms_core_file_failing_command (bfd *abfd);
67 static int vms_core_file_failing_signal (bfd *abfd);
68 static bfd_boolean vms_core_file_matches_executable_p (bfd *abfd, bfd *bbfd);
69 static bfd_boolean vms_slurp_armap (bfd *abfd);
70 static bfd_boolean vms_slurp_extended_name_table (bfd *abfd);
71 static bfd_boolean vms_construct_extended_name_table
72 (bfd *abfd, char **tabloc, bfd_size_type *tablen, const char **name);
73 static void vms_truncate_arname (bfd *abfd, const char *pathname, char *arhdr);
74 static bfd_boolean vms_write_armap
75 (bfd *arch, unsigned int elen, struct orl *map, unsigned int cnt, int idx);
76 static PTR vms_read_ar_hdr (bfd *abfd);
77 static bfd *vms_get_elt_at_index (bfd *abfd, symindex index);
78 static bfd *vms_openr_next_archived_file (bfd *arch, bfd *prev);
79 static bfd_boolean vms_update_armap_timestamp (bfd *abfd);
80 static int vms_generic_stat_arch_elt (bfd *, struct stat *);
81 static long vms_get_symtab_upper_bound (bfd *abfd);
82 static long vms_canonicalize_symtab (bfd *abfd, asymbol **symbols);
83 static void vms_print_symbol (bfd *abfd, PTR file, asymbol *symbol,
84 bfd_print_symbol_type how);
85 static void vms_get_symbol_info (bfd *abfd, asymbol *symbol, symbol_info *ret);
86 static bfd_boolean vms_bfd_is_local_label_name (bfd *abfd, const char *);
87 static alent *vms_get_lineno (bfd *abfd, asymbol *symbol);
88 static bfd_boolean vms_find_nearest_line
89 (bfd *abfd, asection *section, asymbol **symbols, bfd_vma offset,
90 const char **file, const char **func, unsigned int *line);
91 static asymbol *vms_bfd_make_debug_symbol (bfd *abfd, void *ptr,
92 unsigned long size);
93 static long vms_read_minisymbols (bfd *abfd, bfd_boolean dynamic,
94 PTR *minisymsp, unsigned int *sizep);
95 static asymbol *vms_minisymbol_to_symbol
96 (bfd *abfd, bfd_boolean dynamic, const PTR minisym, asymbol *sym);
97 static void alloc_reloc_stream (bfd *abfd, asection *section,
98 void *alloc_error);
99 static bfd_boolean vms_slurp_reloc_table (bfd *abfd, asection *section,
100 asymbol **symbols);
101 static long vms_get_reloc_upper_bound (bfd *abfd, asection *sect);
102 static long vms_canonicalize_reloc (bfd *abfd, asection *srcsec,
103 arelent **location, asymbol **symbols);
104 static const struct reloc_howto_struct *vms_bfd_reloc_type_lookup
105 (bfd *abfd, bfd_reloc_code_real_type code);
106 static bfd_boolean vms_set_arch_mach
107 (bfd *abfd, enum bfd_architecture arch, unsigned long mach);
108 static bfd_boolean vms_set_section_contents
109 (bfd *abfd, asection *section, const PTR location, file_ptr offset,
110 bfd_size_type count);
111 static int vms_sizeof_headers (bfd *abfd,
112 struct bfd_link_info *info ATTRIBUTE_UNUSED);
113 static bfd_byte *vms_bfd_get_relocated_section_contents
114 (bfd *abfd, struct bfd_link_info *link_info,
115 struct bfd_link_order *link_order, bfd_byte *data,
116 bfd_boolean relocatable, asymbol **symbols);
117 static bfd_boolean vms_bfd_relax_section
118 (bfd *abfd, asection *section, struct bfd_link_info *link_info,
119 bfd_boolean *again);
120 static bfd_boolean vms_bfd_gc_sections
121 (bfd *abfd, struct bfd_link_info *link_info);
122 static bfd_boolean vms_bfd_merge_sections
123 (bfd *abfd, struct bfd_link_info *link_info);
124 static struct bfd_link_hash_table *vms_bfd_link_hash_table_create (bfd *abfd);
125 static void vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash);
126 static bfd_boolean vms_bfd_link_add_symbols
127 (bfd *abfd, struct bfd_link_info *link_info);
128 static bfd_boolean vms_bfd_final_link (bfd *abfd,
129 struct bfd_link_info *link_info);
130 static bfd_boolean vms_bfd_link_split_section (bfd *abfd, asection *section);
131 static long vms_get_dynamic_symtab_upper_bound (bfd *abfd);
132 static long vms_canonicalize_dynamic_symtab
133 (bfd *abfd, asymbol **symbols);
134 #define vms_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
135 static long vms_get_dynamic_reloc_upper_bound (bfd *abfd);
136 static long vms_canonicalize_dynamic_reloc
137 (bfd *abfd, arelent **arel, asymbol **symbols);
138 static bfd_boolean vms_bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
139 static bfd_boolean vms_bfd_set_private_flags (bfd *abfd, flagword flags);
141 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
142 #define vms_make_empty_symbol _bfd_generic_make_empty_symbol
143 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
144 #define vms_bfd_is_group_section bfd_generic_is_group_section
145 #define vms_bfd_discard_group bfd_generic_discard_group
146 #define vms_section_already_linked _bfd_generic_section_already_linked
147 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
148 #define vms_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
151 #ifdef VMS_DEBUG
152 /* Cause debug info to be emitted for the structure. */
153 struct vms_private_data_struct _vms_private_data_struct_dummy;
154 struct vms_section_data_struct _vms_section_data_struct_dummy;
155 #endif
157 extern const bfd_target vms_vax_vec;
158 extern const bfd_target vms_alpha_vec;
160 /* Initialize private data */
161 static bfd_boolean
162 vms_initialize (bfd * abfd)
164 bfd_size_type amt;
166 bfd_set_start_address (abfd, (bfd_vma) -1);
168 amt = sizeof (struct vms_private_data_struct);
169 abfd->tdata.any = bfd_zalloc (abfd, amt);
170 if (abfd->tdata.any == NULL)
171 return FALSE;
173 if (bfd_get_flavour (abfd) == bfd_target_ovax_flavour)
174 PRIV (is_vax) = TRUE;
176 PRIV (file_format) = FF_UNKNOWN;
178 amt = sizeof (struct stack_struct) * STACKSIZE;
179 PRIV (stack) = bfd_alloc (abfd, amt);
180 if (PRIV (stack) == NULL)
181 goto error_ret1;
183 amt = sizeof (struct bfd_hash_table);
184 PRIV (vms_symbol_table) = bfd_alloc (abfd, amt);
185 if (PRIV (vms_symbol_table) == NULL)
186 goto error_ret1;
188 if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc,
189 sizeof (vms_symbol_entry)))
190 goto error_ret1;
192 amt = MAX_OUTREC_SIZE;
193 PRIV (output_buf) = bfd_alloc (abfd, amt);
194 if (PRIV (output_buf) == NULL)
195 goto error_ret2;
197 PRIV (length_pos) = 2;
199 return TRUE;
201 error_ret2:
202 bfd_hash_table_free (PRIV (vms_symbol_table));
203 error_ret1:
204 bfd_release (abfd, abfd->tdata.any);
205 abfd->tdata.any = NULL;
206 return FALSE;
209 struct pair
211 unsigned int section_count;
212 asection **sections;
215 /* Fill symbol->section with section pointer.
217 symbol->section is filled with the section index for defined symbols
218 during reading the GSD/EGSD section. But we need the pointer to the
219 bfd section later.
221 It has the correct value for referenced (undefined section) symbols.
223 Called from bfd_hash_traverse in vms_fixup_sections. */
225 static bfd_boolean
226 fill_section_ptr (struct bfd_hash_entry *entry, void *sections)
228 asymbol *sym = ((vms_symbol_entry *)entry)->symbol;
229 struct pair *data = (struct pair *)sections;
230 unsigned long sec = (unsigned long)sym->section;
232 #if VMS_DEBUG
233 vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
234 #endif
236 if (sec < data->section_count)
238 sym->section = data->sections[sec];
240 if (strcmp (sym->name, sym->section->name) == 0)
241 sym->flags |= BSF_SECTION_SYM;
243 else if (sec == (unsigned long)-1)
244 sym->section = &bfd_und_section;
246 return TRUE;
249 /* Fixup section pointers in symbols. */
250 static bfd_boolean
251 vms_fixup_sections (bfd * abfd)
253 struct pair data;
255 if (PRIV (fixup_done))
256 return TRUE;
258 data.section_count = PRIV (section_count);
259 data.sections = PRIV (sections);
260 bfd_hash_traverse (PRIV (vms_symbol_table), fill_section_ptr, &data);
262 PRIV (fixup_done) = TRUE;
263 return TRUE;
266 /* Slurp an ordered set of VMS object records. */
268 _bfd_vms_slurp_object_records (bfd * abfd)
270 int err, new_type, type = -1;
274 #if VMS_DEBUG
275 vms_debug (7, "reading at %08lx\n", bfd_tell (abfd));
276 #endif
277 new_type = _bfd_vms_get_object_record (abfd);
278 if (new_type < 0)
280 #if VMS_DEBUG
281 vms_debug (2, "next_record failed\n");
282 #endif
283 return -1;
286 if (type == EOBJ_S_C_EGSD && new_type != EOBJ_S_C_EGSD)
288 if (! vms_fixup_sections (abfd))
290 #if VMS_DEBUG
291 vms_debug (2, "vms_fixup_sections failed\n");
292 #endif
293 return -1;
297 type = new_type;
299 switch (type)
301 case OBJ_S_C_HDR:
302 case EOBJ_S_C_EMH:
303 err = _bfd_vms_slurp_hdr (abfd, type);
304 break;
305 case OBJ_S_C_EOM:
306 case OBJ_S_C_EOMW:
307 case EOBJ_S_C_EEOM:
308 err = _bfd_vms_slurp_eom (abfd, type);
309 break;
310 case OBJ_S_C_GSD:
311 case EOBJ_S_C_EGSD:
312 err = _bfd_vms_slurp_gsd (abfd, type);
313 break;
314 case OBJ_S_C_TIR:
315 case EOBJ_S_C_ETIR:
316 err = _bfd_vms_slurp_tir (abfd, type);
317 break;
318 case OBJ_S_C_DBG:
319 case EOBJ_S_C_EDBG:
320 err = _bfd_vms_slurp_dbg (abfd, type);
321 PRIV (dst_ptr_end) = PRIV (image_ptr);
322 break;
323 case OBJ_S_C_TBT:
324 case EOBJ_S_C_ETBT:
325 err = _bfd_vms_slurp_tbt (abfd, type);
326 PRIV (dst_ptr_end) = PRIV (image_ptr);
327 break;
328 case OBJ_S_C_LNK:
329 err = _bfd_vms_slurp_lnk (abfd, type);
330 break;
331 default:
332 err = -1;
334 if (err != 0)
336 #if VMS_DEBUG
337 vms_debug (2, "slurp type %d failed with %d\n", type, err);
338 #endif
339 return err;
342 while (type != EOBJ_S_C_EEOM && type != OBJ_S_C_EOM && type != OBJ_S_C_EOMW);
344 return 0;
347 /* Slurp a VMS module and return an error status. */
349 static int
350 vms_slurp_module (bfd *abfd)
352 int type, err;
354 if (PRIV (is_vax))
355 type = PRIV (vms_rec)[0];
356 else
357 type = bfd_getl16 (PRIV (vms_rec));
359 err = _bfd_vms_slurp_hdr (abfd, type);
360 if (err != 0)
362 bfd_set_error (bfd_error_wrong_format);
363 return err;
366 return _bfd_vms_slurp_object_records (abfd);
369 /* Slurp a VMS image and return an error status. */
371 static int
372 vms_slurp_image (bfd *abfd)
374 unsigned int isd_offset, ihs_offset;
375 int err;
377 err = _bfd_vms_slurp_ihd (abfd, &isd_offset, &ihs_offset);
378 if (err != 0)
380 bfd_set_error (bfd_error_wrong_format);
381 return err;
384 err = _bfd_vms_slurp_isd (abfd, isd_offset);
385 if (err != 0)
387 bfd_set_error (bfd_error_wrong_format);
388 return err;
391 return _bfd_vms_slurp_ihs (abfd, ihs_offset);
394 /* Check the format for a file being read.
395 Return a (bfd_target *) if it's an object file or zero if not. */
397 static const struct bfd_target *
398 vms_object_p (bfd *abfd)
400 const struct bfd_target *target_vector;
401 const bfd_arch_info_type *arch;
402 PTR tdata_save = abfd->tdata.any;
403 bfd_vma saddr_save = bfd_get_start_address (abfd);
404 int err = 0;
406 #if VMS_DEBUG
407 vms_debug (1, "vms_object_p(%p)\n", abfd);
408 #endif
410 if (!vms_initialize (abfd))
411 goto error_ret;
413 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
414 goto err_wrong_format;
416 switch (_bfd_vms_get_first_record (abfd))
418 case FT_UNKNOWN:
419 default:
420 err = -1;
421 break;
423 case FT_MODULE:
424 err = vms_slurp_module (abfd);
425 break;
427 case FT_IMAGE:
428 err = vms_slurp_image (abfd);
429 break;
432 if (err != 0)
433 goto err_wrong_format;
435 if (PRIV (is_vax))
437 if (! vms_fixup_sections (abfd))
439 #if VMS_DEBUG
440 vms_debug (2, "vms_fixup_sections failed\n");
441 #endif
442 goto err_wrong_format;
445 target_vector = &vms_vax_vec;
446 arch = bfd_scan_arch ("vax");
448 #if VMS_DEBUG
449 vms_debug (2, "arch is vax\n");
450 #endif
452 else
454 /* Set arch_info to alpha. */
455 target_vector = &vms_alpha_vec;
456 arch = bfd_scan_arch ("alpha");
457 #if VMS_DEBUG
458 vms_debug (2, "arch is alpha\n");
459 #endif
462 abfd->arch_info = arch;
463 return target_vector;
465 err_wrong_format:
466 bfd_set_error (bfd_error_wrong_format);
468 error_ret:
469 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
470 bfd_release (abfd, abfd->tdata.any);
471 abfd->tdata.any = tdata_save;
472 bfd_set_start_address (abfd, saddr_save);
473 return NULL;
476 /* Check the format for a file being read.
477 Return a (bfd_target *) if it's an archive file or zero. */
479 static const struct bfd_target *
480 vms_archive_p (bfd * abfd ATTRIBUTE_UNUSED)
482 #if VMS_DEBUG
483 vms_debug (1, "vms_archive_p (%p)\n", abfd);
484 #endif
486 return NULL;
489 /* Set the format of a file being written. */
491 static bfd_boolean
492 vms_mkobject (bfd * abfd)
494 const bfd_arch_info_type *arch;
496 #if VMS_DEBUG
497 vms_debug (1, "vms_mkobject (%p)\n", abfd);
498 #endif
500 if (!vms_initialize (abfd))
501 return FALSE;
503 if (PRIV (is_vax))
504 arch = bfd_scan_arch ("vax");
505 else
506 arch = bfd_scan_arch ("alpha");
508 if (arch == 0)
510 bfd_set_error(bfd_error_wrong_format);
511 return FALSE;
514 abfd->arch_info = arch;
515 return TRUE;
518 /* Write cached information into a file being written, at bfd_close. */
520 static bfd_boolean
521 vms_write_object_contents (bfd * abfd)
523 #if VMS_DEBUG
524 vms_debug (1, "vms_write_object_contents (%p)\n", abfd);
525 #endif
527 if (abfd->section_count > 0) /* we have sections */
529 if (PRIV (is_vax))
531 if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0)
532 return FALSE;
533 if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0)
534 return FALSE;
535 if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0)
536 return FALSE;
537 if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0)
538 return FALSE;
539 if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0)
540 return FALSE;
541 if (abfd->section_count > 255)
543 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
544 return FALSE;
546 else
548 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
549 return FALSE;
552 else
554 if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0)
555 return FALSE;
556 if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0)
557 return FALSE;
558 if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0)
559 return FALSE;
560 if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0)
561 return FALSE;
562 if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0)
563 return FALSE;
564 if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0)
565 return FALSE;
568 return TRUE;
571 /* 4.1, generic. */
573 /* Free the reloc buffer for the specified section. */
575 static void
576 free_reloc_stream (bfd *abfd ATTRIBUTE_UNUSED, asection *section,
577 void *data ATTRIBUTE_UNUSED)
579 if (vms_section_data (section)->reloc_stream)
580 free (vms_section_data (section)->reloc_stream);
583 #ifdef VMS
584 /* Convert the file to variable record length format. This is done
585 using undocumented system call sys$modify().
586 Pure VMS version. */
588 static void
589 vms_convert_to_var (char *vms_filename)
591 struct FAB fab = cc$rms_fab;
593 fab.fab$l_fna = vms_filename;
594 fab.fab$b_fns = strlen (vms_filename);
595 fab.fab$b_fac = FAB$M_PUT;
596 fab.fab$l_fop = FAB$M_ESC;
597 fab.fab$l_ctx = RME$C_SETRFM;
599 sys$open (&fab);
601 fab.fab$b_rfm = FAB$C_VAR;
603 sys$modify (&fab);
604 sys$close (&fab);
607 static int
608 vms_convert_to_var_1 (char *filename, int type)
610 if (type != DECC$K_FILE)
611 return FALSE;
612 vms_convert_to_var (filename);
613 return TRUE;
616 /* Convert the file to variable record length format. This is done
617 using undocumented system call sys$modify().
618 Unix filename version. */
620 static int
621 vms_convert_to_var_unix_filename (const char *unix_filename)
623 if (decc$to_vms (unix_filename, &vms_convert_to_var_1, 0, 1) != 1)
624 return FALSE;
625 return TRUE;
627 #endif /* VMS */
629 /* Called when the BFD is being closed to do any necessary cleanup. */
631 static bfd_boolean
632 vms_close_and_cleanup (bfd * abfd)
634 #if VMS_DEBUG
635 vms_debug (1, "vms_close_and_cleanup (%p)\n", abfd);
636 #endif
637 if (abfd == NULL || abfd->tdata.any == NULL)
638 return TRUE;
640 if (PRIV (vms_buf) != NULL)
641 free (PRIV (vms_buf));
643 if (PRIV (sections) != NULL)
644 free (PRIV (sections));
646 if (PRIV (vms_symbol_table))
647 bfd_hash_table_free (PRIV (vms_symbol_table));
649 bfd_map_over_sections (abfd, free_reloc_stream, NULL);
651 bfd_release (abfd, abfd->tdata.any);
652 abfd->tdata.any = NULL;
654 #ifdef VMS
655 if (abfd->direction == write_direction)
657 /* Last step on VMS is to convert the file to variable record length
658 format. */
659 if (bfd_cache_close (abfd) != TRUE)
660 return FALSE;
661 if (vms_convert_to_var_unix_filename (abfd->filename) != TRUE)
662 return FALSE;
664 #endif
666 return TRUE;
669 /* Ask the BFD to free all cached information. */
671 static bfd_boolean
672 vms_bfd_free_cached_info (bfd * abfd ATTRIBUTE_UNUSED)
674 #if VMS_DEBUG
675 vms_debug (1, "vms_bfd_free_cached_info (%p)\n", abfd);
676 #endif
677 return TRUE;
680 /* Called when a new section is created. */
682 static bfd_boolean
683 vms_new_section_hook (bfd * abfd, asection *section)
685 bfd_size_type amt;
687 /* Count hasn't been incremented yet. */
688 unsigned int section_count = abfd->section_count + 1;
690 #if VMS_DEBUG
691 vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
692 abfd, section->index, section->name, section_count);
693 #endif
695 bfd_set_section_alignment (abfd, section, 0);
697 if (section_count > PRIV (section_count))
699 bfd_size_type amt = section_count;
700 amt *= sizeof (asection *);
701 PRIV (sections) = bfd_realloc_or_free (PRIV (sections), amt);
702 if (PRIV (sections) == NULL)
703 return FALSE;
704 PRIV (section_count) = section_count;
707 #if VMS_DEBUG
708 vms_debug (6, "section_count: %d\n", PRIV (section_count));
709 #endif
711 PRIV (sections)[section->index] = section;
713 #if VMS_DEBUG
714 vms_debug (7, "%d: %s\n", section->index, section->name);
715 #endif
717 amt = sizeof (struct vms_section_data_struct);
718 section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
719 if (section->used_by_bfd == NULL)
720 return FALSE;
722 return _bfd_generic_new_section_hook (abfd, section);
725 /* Read the contents of a section.
726 buf points to a buffer of buf_size bytes to be filled with
727 section data (starting at offset into section) */
729 static bfd_boolean
730 vms_get_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
731 asection *section ATTRIBUTE_UNUSED,
732 void * buf ATTRIBUTE_UNUSED,
733 file_ptr offset ATTRIBUTE_UNUSED,
734 bfd_size_type buf_size ATTRIBUTE_UNUSED)
736 bfd_size_type size = section->size;
738 #if VMS_DEBUG
739 vms_debug (1, "vms_get_section_contents (%p, %s, %p, off %ld, size %d)\n",
740 abfd, section->name, buf, offset, (int)buf_size);
741 #endif
743 if (section->contents)
744 abort ();
746 section->contents = (unsigned char *) bfd_malloc (size);
748 if (section->contents == NULL)
750 bfd_set_error (bfd_error_no_memory);
751 return FALSE;
754 if (bfd_seek (abfd, section->filepos, SEEK_SET))
756 bfd_set_error (bfd_error_file_truncated);
757 return FALSE;
760 if (bfd_bread (section->contents, size, abfd) != size)
762 bfd_set_error (bfd_error_file_truncated);
763 return FALSE;
766 section->flags |= SEC_IN_MEMORY;
768 if (buf)
769 memcpy (buf, section->contents + offset, (size_t) buf_size);
771 return TRUE;
774 /* Read the contents of a section.
775 buf points to a buffer of buf_size bytes to be filled with
776 section data (starting at offset into section). */
778 static bfd_boolean
779 vms_get_section_contents_in_window (bfd * abfd ATTRIBUTE_UNUSED,
780 asection *section ATTRIBUTE_UNUSED,
781 bfd_window *w ATTRIBUTE_UNUSED,
782 file_ptr offset ATTRIBUTE_UNUSED,
783 bfd_size_type count ATTRIBUTE_UNUSED)
785 #if VMS_DEBUG
786 vms_debug (1, "vms_get_section_contents_in_window (%p, %s, %p, off %ld, count %d)\n",
787 abfd, section->name, w, offset, (int)count);
788 #endif
790 /* Shouldn't be called, since all sections are IN_MEMORY. */
791 return FALSE;
794 /* Part 4.2, copy private data. */
796 /* Called to copy BFD general private data from one object file
797 to another. */
799 static bfd_boolean
800 vms_bfd_copy_private_bfd_data (bfd *src ATTRIBUTE_UNUSED,
801 bfd *dest ATTRIBUTE_UNUSED)
803 #if VMS_DEBUG
804 vms_debug (1, "vms_bfd_copy_private_bfd_data (%p, %p)\n", src, dest);
805 #endif
806 return TRUE;
809 /* Merge private BFD information from the BFD @var{ibfd} to the
810 the output file BFD @var{obfd} when linking. Return <<TRUE>>
811 on success, <<FALSE>> on error. Possible error returns are:
813 o <<bfd_error_no_memory>> -
814 Not enough memory exists to create private data for @var{obfd}. */
816 static bfd_boolean
817 vms_bfd_merge_private_bfd_data (bfd * ibfd ATTRIBUTE_UNUSED,
818 bfd * obfd ATTRIBUTE_UNUSED)
820 #if VMS_DEBUG
821 vms_debug (1,"vms_bfd_merge_private_bfd_data (%p, %p)\n", ibfd, obfd);
822 #endif
823 return TRUE;
826 /* Set private BFD flag information in the BFD @var{abfd}.
827 Return <<TRUE>> on success, <<FALSE>> on error. Possible error
828 returns are:
830 o <<bfd_error_no_memory>> -
831 Not enough memory exists to create private data for @var{obfd}. */
833 static bfd_boolean
834 vms_bfd_set_private_flags (bfd * abfd ATTRIBUTE_UNUSED,
835 flagword flags ATTRIBUTE_UNUSED)
837 #if VMS_DEBUG
838 vms_debug (1,"vms_bfd_set_private_flags (%p, %lx)\n", abfd, (long)flags);
839 #endif
840 return TRUE;
843 /* Called to copy BFD private section data from one object file
844 to another. */
846 static bfd_boolean
847 vms_bfd_copy_private_section_data (bfd *srcbfd ATTRIBUTE_UNUSED,
848 asection *srcsec ATTRIBUTE_UNUSED,
849 bfd *dstbfd ATTRIBUTE_UNUSED,
850 asection *dstsec ATTRIBUTE_UNUSED)
852 #if VMS_DEBUG
853 vms_debug (1, "vms_bfd_copy_private_section_data (%p, %s, %p, %s)\n",
854 srcbfd, srcsec->name, dstbfd, dstsec->name);
855 #endif
856 return TRUE;
859 /* Called to copy BFD private symbol data from one object file
860 to another. */
862 static bfd_boolean
863 vms_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED,
864 asymbol *isym ATTRIBUTE_UNUSED,
865 bfd *obfd ATTRIBUTE_UNUSED,
866 asymbol *osym ATTRIBUTE_UNUSED)
868 #if VMS_DEBUG
869 vms_debug (1, "vms_bfd_copy_private_symbol_data (%p, %s, %p, %s)\n",
870 ibfd, isym->name, obfd, osym->name);
871 #endif
872 return TRUE;
875 /* Part 4.3, core file. */
877 /* Return a read-only string explaining which program was running
878 when it failed and produced the core file abfd. */
880 static char *
881 vms_core_file_failing_command (bfd * abfd ATTRIBUTE_UNUSED)
883 #if VMS_DEBUG
884 vms_debug (1, "vms_core_file_failing_command (%p)\n", abfd);
885 #endif
886 return NULL;
889 /* Returns the signal number which caused the core dump which
890 generated the file the BFD abfd is attached to. */
892 static int
893 vms_core_file_failing_signal (bfd * abfd ATTRIBUTE_UNUSED)
895 #if VMS_DEBUG
896 vms_debug (1, "vms_core_file_failing_signal (%p)\n", abfd);
897 #endif
898 return 0;
901 /* Return TRUE if the core file attached to core_bfd was generated
902 by a run of the executable file attached to exec_bfd, FALSE otherwise. */
904 static bfd_boolean
905 vms_core_file_matches_executable_p (bfd * abfd ATTRIBUTE_UNUSED,
906 bfd *bbfd ATTRIBUTE_UNUSED)
908 #if VMS_DEBUG
909 vms_debug (1, "vms_core_file_matches_executable_p (%p, %p)\n", abfd, bbfd);
910 #endif
911 return FALSE;
914 /* Part 4.4, archive. */
916 /* ??? do something with an archive map.
917 Return FALSE on error, TRUE otherwise. */
919 static bfd_boolean
920 vms_slurp_armap (bfd * abfd ATTRIBUTE_UNUSED)
922 #if VMS_DEBUG
923 vms_debug (1, "vms_slurp_armap (%p)\n", abfd);
924 #endif
925 return FALSE;
928 /* ??? do something with an extended name table.
929 Return FALSE on error, TRUE otherwise. */
931 static bfd_boolean
932 vms_slurp_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED)
934 #if VMS_DEBUG
935 vms_debug (1, "vms_slurp_extended_name_table (%p)\n", abfd);
936 #endif
937 return FALSE;
940 /* ??? do something with an extended name table.
941 Return FALSE on error, TRUE otherwise. */
943 static bfd_boolean
944 vms_construct_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED,
945 char **tabloc ATTRIBUTE_UNUSED,
946 bfd_size_type *tablen ATTRIBUTE_UNUSED,
947 const char **name ATTRIBUTE_UNUSED)
949 #if VMS_DEBUG
950 vms_debug (1, "vms_construct_extended_name_table (%p)\n", abfd);
951 #endif
952 return FALSE;
955 /* Truncate the name of an archive to match system-dependent restrictions. */
957 static void
958 vms_truncate_arname (bfd * abfd ATTRIBUTE_UNUSED,
959 const char *pathname ATTRIBUTE_UNUSED,
960 char *arhdr ATTRIBUTE_UNUSED)
962 #if VMS_DEBUG
963 vms_debug (1, "vms_truncate_arname (%p, %s, %s)\n", abfd, pathname, arhdr);
964 #endif
967 /* ??? write archive map. */
969 static bfd_boolean
970 vms_write_armap (bfd *arch ATTRIBUTE_UNUSED,
971 unsigned int elength ATTRIBUTE_UNUSED,
972 struct orl *map ATTRIBUTE_UNUSED,
973 unsigned int orl_count ATTRIBUTE_UNUSED,
974 int stridx ATTRIBUTE_UNUSED)
976 #if VMS_DEBUG
977 vms_debug (1, "vms_write_armap (%p, %d, %p, %d %d)\n",
978 arch, elength, map, orl_count, stridx);
979 #endif
980 return TRUE;
983 /* Read archive header ??? */
985 static void *
986 vms_read_ar_hdr (bfd * abfd ATTRIBUTE_UNUSED)
988 #if VMS_DEBUG
989 vms_debug (1, "vms_read_ar_hdr (%p)\n", abfd);
990 #endif
991 return NULL;
994 /* Provided a BFD, @var{archive}, containing an archive and NULL, open
995 an input BFD on the first contained element and returns that.
996 Subsequent calls should pass the archive and the previous return value
997 to return a created BFD to the next contained element.
998 NULL is returned when there are no more. */
1000 static bfd *
1001 vms_openr_next_archived_file (bfd *arch ATTRIBUTE_UNUSED,
1002 bfd *prev ATTRIBUTE_UNUSED)
1004 #if VMS_DEBUG
1005 vms_debug (1, "vms_openr_next_archived_file (%p, %p)\n", arch, prev);
1006 #endif
1007 return NULL;
1010 /* Return the BFD which is referenced by the symbol in ABFD indexed by
1011 INDEX. INDEX should have been returned by bfd_get_next_mapent. */
1013 static bfd *
1014 vms_get_elt_at_index (bfd * abfd, symindex index)
1016 #if VMS_DEBUG
1017 vms_debug (1, "vms_get_elt_at_index (%p, %p)\n", abfd, index);
1018 #endif
1019 return _bfd_generic_get_elt_at_index (abfd, index);
1022 /* ???
1023 -> bfd_generic_stat_arch_elt. */
1025 static int
1026 vms_generic_stat_arch_elt (bfd * abfd, struct stat *st)
1028 #if VMS_DEBUG
1029 vms_debug (1, "vms_generic_stat_arch_elt (%p, %p)\n", abfd, st);
1030 #endif
1031 return bfd_generic_stat_arch_elt (abfd, st);
1034 /* This is a new function in bfd 2.5. */
1036 static bfd_boolean
1037 vms_update_armap_timestamp (bfd * abfd ATTRIBUTE_UNUSED)
1039 #if VMS_DEBUG
1040 vms_debug (1, "vms_update_armap_timestamp (%p)\n", abfd);
1041 #endif
1042 return TRUE;
1045 /* Part 4.5, symbols. */
1047 /* Return the number of bytes required to store a vector of pointers
1048 to asymbols for all the symbols in the BFD abfd, including a
1049 terminal NULL pointer. If there are no symbols in the BFD,
1050 then return 0. If an error occurs, return -1. */
1052 static long
1053 vms_get_symtab_upper_bound (bfd * abfd)
1055 #if VMS_DEBUG
1056 vms_debug (1, "vms_get_symtab_upper_bound (%p), %d symbols\n", abfd, PRIV (gsd_sym_count));
1057 #endif
1058 return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *);
1061 /* Copy symbols from hash table to symbol vector
1063 called from bfd_hash_traverse in vms_canonicalize_symtab
1064 init counter to 0 if entry == 0. */
1066 static bfd_boolean
1067 copy_symbols (struct bfd_hash_entry *entry, void * arg)
1069 bfd * abfd = (bfd *) arg;
1071 if (entry == NULL) /* Init counter. */
1072 PRIV (symnum) = 0;
1073 else /* Fill vector, inc counter. */
1074 PRIV (symcache)[PRIV (symnum)++] = ((vms_symbol_entry *)entry)->symbol;
1076 return TRUE;
1079 /* Read the symbols from the BFD abfd, and fills in the vector
1080 location with pointers to the symbols and a trailing NULL.
1082 Return number of symbols read. */
1084 static long
1085 vms_canonicalize_symtab (bfd * abfd, asymbol **symbols)
1087 #if VMS_DEBUG
1088 vms_debug (1, "vms_canonicalize_symtab (%p, <ret>)\n", abfd);
1089 #endif
1091 /* Init counter. */
1092 copy_symbols (NULL, abfd);
1094 /* Traverse table and fill symbols vector. */
1095 PRIV (symcache) = symbols;
1096 bfd_hash_traverse (PRIV (vms_symbol_table), copy_symbols, abfd);
1098 symbols[PRIV (gsd_sym_count)] = NULL;
1100 return PRIV (gsd_sym_count);
1103 /* Print symbol to file according to how. how is one of
1104 bfd_print_symbol_name just print the name
1105 bfd_print_symbol_more print more (???)
1106 bfd_print_symbol_all print all we know, which is not much right now :-). */
1108 static void
1109 vms_print_symbol (bfd * abfd,
1110 void * file,
1111 asymbol *symbol,
1112 bfd_print_symbol_type how)
1114 #if VMS_DEBUG
1115 vms_debug (1, "vms_print_symbol (%p, %p, %p, %d)\n", abfd, file, symbol, how);
1116 #endif
1118 switch (how)
1120 case bfd_print_symbol_name:
1121 case bfd_print_symbol_more:
1122 fprintf ((FILE *)file," %s", symbol->name);
1123 break;
1125 case bfd_print_symbol_all:
1127 const char *section_name = symbol->section->name;
1129 bfd_print_symbol_vandf (abfd, file, symbol);
1131 fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
1133 break;
1137 /* Return information about symbol in ret.
1139 fill type, value and name
1140 type:
1141 A absolute
1142 B bss segment symbol
1143 C common symbol
1144 D data segment symbol
1145 f filename
1146 t a static function symbol
1147 T text segment symbol
1148 U undefined
1149 - debug. */
1151 static void
1152 vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
1153 asymbol *symbol,
1154 symbol_info *ret)
1156 asection *sec;
1158 #if VMS_DEBUG
1159 vms_debug (1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret);
1160 #endif
1162 sec = symbol->section;
1164 if (ret == NULL)
1165 return;
1167 if (sec == 0)
1168 ret->type = 'U';
1169 else if (bfd_is_com_section (sec))
1170 ret->type = 'C';
1171 else if (bfd_is_abs_section (sec))
1172 ret->type = 'A';
1173 else if (bfd_is_und_section (sec))
1174 ret->type = 'U';
1175 else if (bfd_is_ind_section (sec))
1176 ret->type = 'I';
1177 else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
1178 ret->type = 'T';
1179 else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
1180 ret->type = 'D';
1181 else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
1182 ret->type = 'B';
1183 else
1184 ret->type = '-';
1186 if (ret->type != 'U')
1187 ret->value = symbol->value + symbol->section->vma;
1188 else
1189 ret->value = 0;
1190 ret->name = symbol->name;
1193 /* Return TRUE if the given symbol sym in the BFD abfd is
1194 a compiler generated local label, else return FALSE. */
1196 static bfd_boolean
1197 vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
1198 const char *name)
1200 #if VMS_DEBUG
1201 vms_debug (1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd, name);
1202 #endif
1203 return name[0] == '$';
1206 /* Get source line number for symbol. */
1208 static alent *
1209 vms_get_lineno (bfd * abfd ATTRIBUTE_UNUSED,
1210 asymbol *symbol ATTRIBUTE_UNUSED)
1212 #if VMS_DEBUG
1213 vms_debug (1, "vms_get_lineno (%p, %p)\n", abfd, symbol);
1214 #endif
1215 return NULL;
1218 /* Provided a BFD, a section and an offset into the section, calculate and
1219 return the name of the source file and the line nearest to the wanted
1220 location. */
1222 static bfd_boolean
1223 vms_find_nearest_line (bfd * abfd ATTRIBUTE_UNUSED,
1224 asection *section ATTRIBUTE_UNUSED,
1225 asymbol **symbols ATTRIBUTE_UNUSED,
1226 bfd_vma offset ATTRIBUTE_UNUSED,
1227 const char **file ATTRIBUTE_UNUSED,
1228 const char **func ATTRIBUTE_UNUSED,
1229 unsigned int *line ATTRIBUTE_UNUSED)
1231 #if VMS_DEBUG
1232 vms_debug (1, "vms_find_nearest_line (%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
1233 abfd, section->name, symbols, (long int)offset);
1234 #endif
1235 return _bfd_vms_find_nearest_dst_line (abfd, section, symbols, offset, file, func, line);
1238 static bfd_boolean
1239 vms_find_inliner_info (bfd * abfd ATTRIBUTE_UNUSED,
1240 const char **file ATTRIBUTE_UNUSED,
1241 const char **func ATTRIBUTE_UNUSED,
1242 unsigned int *line ATTRIBUTE_UNUSED)
1244 #if VMS_DEBUG
1245 vms_debug (1, "vms_find_inliner_info (%p, <ret>, <ret>, <ret>)\n",
1246 abfd);
1247 #endif
1248 return FALSE;
1251 /* Back-door to allow format-aware applications to create debug symbols
1252 while using BFD for everything else. Currently used by the assembler
1253 when creating COFF files. */
1255 static asymbol *
1256 vms_bfd_make_debug_symbol (bfd * abfd ATTRIBUTE_UNUSED,
1257 void *ptr ATTRIBUTE_UNUSED,
1258 unsigned long size ATTRIBUTE_UNUSED)
1260 #if VMS_DEBUG
1261 vms_debug (1, "vms_bfd_make_debug_symbol (%p, %p, %ld)\n", abfd, ptr, size);
1262 #endif
1263 return NULL;
1266 /* Read minisymbols. For minisymbols, we use the unmodified a.out
1267 symbols. The minisymbol_to_symbol function translates these into
1268 BFD asymbol structures. */
1270 static long
1271 vms_read_minisymbols (bfd * abfd,
1272 bfd_boolean dynamic,
1273 void * *minisymsp,
1274 unsigned int *sizep)
1276 #if VMS_DEBUG
1277 vms_debug (1, "vms_read_minisymbols (%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
1278 #endif
1279 return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
1282 /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1283 unmodified a.out symbol. The SYM argument is a structure returned
1284 by bfd_make_empty_symbol, which we fill in here. */
1286 static asymbol *
1287 vms_minisymbol_to_symbol (bfd * abfd,
1288 bfd_boolean dynamic,
1289 const void * minisym,
1290 asymbol *sym)
1292 #if VMS_DEBUG
1293 vms_debug (1, "vms_minisymbol_to_symbol (%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
1294 #endif
1295 return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
1298 /* Part 4.6, relocations. */
1300 /* Allocate the reloc buffer for the specified section. */
1302 static void
1303 alloc_reloc_stream (bfd *abfd ATTRIBUTE_UNUSED, asection *section,
1304 void *alloc_error)
1306 unsigned char *ptr;
1308 /* If there were no relocations, there is nothing to do. */
1309 if (section->reloc_count == 0)
1310 return;
1312 ptr = bfd_malloc (vms_section_data (section)->reloc_size);
1313 if (ptr == NULL)
1315 *(bfd_boolean *)alloc_error = TRUE;
1316 return;
1319 vms_section_data (section)->reloc_stream = ptr;
1322 /* Read in the relocs for the specified section and internalize them.
1324 The implementation is loosely based on the SOM code and made up
1325 of 3 distinct phases:
1327 1. When the VMS object is opened and parsed, the number and the size
1328 of the relocations are computed for all sections. This makes it
1329 possible to know upfront both which sections have no relocs and
1330 the size of the reloc buffers for the other sections, at virtually
1331 no cost for consumers that don't care about relocs at all.
1333 2. When vms_slurp_reloc_table is invoked for the first time on a section
1334 with relocs, the object is traversed and all the reloc information
1335 is saved in per-section reloc buffers. It would be very inefficient
1336 to scan the whole file on each invocation, so we slurp for all the
1337 sections at once.
1339 3. On subsequent invocations of vms_slurp_reloc_table, the relocs for the
1340 specified section are fetched from the buffer, decoded and internalized.
1341 The buffer is then freed since the internalized relocs are attached to
1342 the section, turning additional invocations of vms_slurp_reloc_table
1343 on the same section into no-ops.
1345 Since VMS objects have very few sections, it could be profitable to merge
1346 phase #2 and phase #3, i.e. to decode and internalize the relocs for all
1347 the sections at once. The current implementation is more elegant. */
1349 static bfd_boolean
1350 vms_slurp_reloc_table (bfd *abfd, asection *section, asymbol **symbols)
1352 arelent *internal_relocs;
1353 bfd_size_type amt;
1354 int err;
1356 /* If there were no relocations, there is nothing to do. */
1357 if (section->reloc_count == 0)
1358 return TRUE;
1360 /* Return saved information about the relocations if it is available. */
1361 if (section->relocation != NULL)
1362 return TRUE;
1364 /* If the relocation stream has not been slurped, do it now. */
1365 if (vms_section_data (section)->reloc_stream == NULL)
1367 bfd_boolean alloc_error = FALSE;
1368 int type;
1370 /* Size the reloc buffer for each section. */
1371 bfd_map_over_sections (abfd, alloc_reloc_stream, &alloc_error);
1372 if (alloc_error)
1373 return FALSE;
1375 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
1376 return FALSE;
1378 /* Reset section pointer. */
1379 PRIV (image_section) = NULL;
1383 type = _bfd_vms_get_object_record (abfd);
1384 if (type != EOBJ_S_C_ETIR
1385 && type != EOBJ_S_C_EDBG
1386 && type != EOBJ_S_C_ETBT)
1387 continue;
1388 err = _bfd_vms_slurp_relocs (abfd);
1389 if (err != 0)
1391 #if VMS_DEBUG
1392 vms_debug (2, "slurp relocs failed with %d\n", err);
1393 #endif
1394 return FALSE;
1397 while (type != EOBJ_S_C_EEOM);
1400 amt = section->reloc_count * sizeof (arelent);
1401 internal_relocs = (arelent *) bfd_zalloc (abfd, amt);
1402 if (internal_relocs == NULL)
1403 return FALSE;
1405 /* Decode and internalize the relocations. */
1406 err = _bfd_vms_decode_relocs (abfd, internal_relocs, section, symbols);
1407 if (err != 0)
1409 #if VMS_DEBUG
1410 vms_debug (2, "decode relocs failed with %d\n", err);
1411 #endif
1412 return FALSE;
1415 /* We're done with the external relocations. Free them. */
1416 free (vms_section_data (section)->reloc_stream);
1417 vms_section_data (section)->reloc_stream = NULL;
1419 /* Save our results and return success. */
1420 section->relocation = internal_relocs;
1421 return TRUE;
1424 /* Return the number of bytes required to store the relocation
1425 information associated with the given section. */
1427 static long
1428 vms_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *section)
1430 return (section->reloc_count + 1) * sizeof (arelent *);
1433 /* Convert relocations from VMS (external) form into BFD internal
1434 form. Return the number of relocations. */
1436 static long
1437 vms_canonicalize_reloc (bfd *abfd, asection *section, arelent **relptr,
1438 asymbol **symbols)
1440 arelent *tblptr;
1441 int count;
1443 if (! vms_slurp_reloc_table (abfd, section, symbols))
1444 return -1;
1446 count = section->reloc_count;
1447 tblptr = section->relocation;
1449 while (count--)
1450 *relptr++ = tblptr++;
1452 *relptr = (arelent *) NULL;
1453 return section->reloc_count;
1456 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
1458 /* How to process the various reloc types. */
1460 static bfd_reloc_status_type
1461 reloc_nil (bfd * abfd ATTRIBUTE_UNUSED,
1462 arelent *reloc ATTRIBUTE_UNUSED,
1463 asymbol *sym ATTRIBUTE_UNUSED,
1464 void * data ATTRIBUTE_UNUSED,
1465 asection *sec ATTRIBUTE_UNUSED,
1466 bfd *output_bfd ATTRIBUTE_UNUSED,
1467 char **error_message ATTRIBUTE_UNUSED)
1469 #if VMS_DEBUG
1470 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd);
1471 vms_debug (2, "In section %s, symbol %s\n",
1472 sec->name, sym->name);
1473 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1474 reloc->sym_ptr_ptr[0]->name,
1475 (unsigned long)reloc->address,
1476 (unsigned long)reloc->addend, reloc->howto->name);
1477 vms_debug (2, "data at %p\n", data);
1478 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
1479 #endif
1481 return bfd_reloc_ok;
1484 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1485 from smaller values. Start with zero, widen, *then* decrement. */
1486 #define MINUS_ONE (((bfd_vma)0) - 1)
1488 static reloc_howto_type alpha_howto_table[] =
1490 HOWTO (ALPHA_R_IGNORE, /* Type. */
1491 0, /* Rightshift. */
1492 0, /* Size (0 = byte, 1 = short, 2 = long). */
1493 8, /* Bitsize. */
1494 TRUE, /* PC relative. */
1495 0, /* Bitpos. */
1496 complain_overflow_dont,/* Complain_on_overflow. */
1497 reloc_nil, /* Special_function. */
1498 "IGNORE", /* Name. */
1499 TRUE, /* Partial_inplace. */
1500 0, /* Source mask */
1501 0, /* Dest mask. */
1502 TRUE), /* PC rel offset. */
1504 /* A 64 bit reference to a symbol. */
1505 HOWTO (ALPHA_R_REFQUAD, /* Type. */
1506 0, /* Rightshift. */
1507 4, /* Size (0 = byte, 1 = short, 2 = long). */
1508 64, /* Bitsize. */
1509 FALSE, /* PC relative. */
1510 0, /* Bitpos. */
1511 complain_overflow_bitfield, /* Complain_on_overflow. */
1512 reloc_nil, /* Special_function. */
1513 "REFQUAD", /* Name. */
1514 TRUE, /* Partial_inplace. */
1515 MINUS_ONE, /* Source mask. */
1516 MINUS_ONE, /* Dest mask. */
1517 FALSE), /* PC rel offset. */
1519 /* A 21 bit branch. The native assembler generates these for
1520 branches within the text segment, and also fills in the PC
1521 relative offset in the instruction. */
1522 HOWTO (ALPHA_R_BRADDR, /* Type. */
1523 2, /* Rightshift. */
1524 2, /* Size (0 = byte, 1 = short, 2 = long). */
1525 21, /* Bitsize. */
1526 TRUE, /* PC relative. */
1527 0, /* Bitpos. */
1528 complain_overflow_signed, /* Complain_on_overflow. */
1529 reloc_nil, /* Special_function. */
1530 "BRADDR", /* Name. */
1531 TRUE, /* Partial_inplace. */
1532 0x1fffff, /* Source mask. */
1533 0x1fffff, /* Dest mask. */
1534 FALSE), /* PC rel offset. */
1536 /* A hint for a jump to a register. */
1537 HOWTO (ALPHA_R_HINT, /* Type. */
1538 2, /* Rightshift. */
1539 1, /* Size (0 = byte, 1 = short, 2 = long). */
1540 14, /* Bitsize. */
1541 TRUE, /* PC relative. */
1542 0, /* Bitpos. */
1543 complain_overflow_dont,/* Complain_on_overflow. */
1544 reloc_nil, /* Special_function. */
1545 "HINT", /* Name. */
1546 TRUE, /* Partial_inplace. */
1547 0x3fff, /* Source mask. */
1548 0x3fff, /* Dest mask. */
1549 FALSE), /* PC rel offset. */
1551 /* 16 bit PC relative offset. */
1552 HOWTO (ALPHA_R_SREL16, /* Type. */
1553 0, /* Rightshift. */
1554 1, /* Size (0 = byte, 1 = short, 2 = long). */
1555 16, /* Bitsize. */
1556 TRUE, /* PC relative. */
1557 0, /* Bitpos. */
1558 complain_overflow_signed, /* Complain_on_overflow. */
1559 reloc_nil, /* Special_function. */
1560 "SREL16", /* Name. */
1561 TRUE, /* Partial_inplace. */
1562 0xffff, /* Source mask. */
1563 0xffff, /* Dest mask. */
1564 FALSE), /* PC rel offset. */
1566 /* 32 bit PC relative offset. */
1567 HOWTO (ALPHA_R_SREL32, /* Type. */
1568 0, /* Rightshift. */
1569 2, /* Size (0 = byte, 1 = short, 2 = long). */
1570 32, /* Bitsize. */
1571 TRUE, /* PC relative. */
1572 0, /* Bitpos. */
1573 complain_overflow_signed, /* Complain_on_overflow. */
1574 reloc_nil, /* Special_function. */
1575 "SREL32", /* Name. */
1576 TRUE, /* Partial_inplace. */
1577 0xffffffff, /* Source mask. */
1578 0xffffffff, /* Dest mask. */
1579 FALSE), /* PC rel offset. */
1581 /* A 64 bit PC relative offset. */
1582 HOWTO (ALPHA_R_SREL64, /* Type. */
1583 0, /* Rightshift. */
1584 4, /* Size (0 = byte, 1 = short, 2 = long). */
1585 64, /* Bitsize. */
1586 TRUE, /* PC relative. */
1587 0, /* Bitpos. */
1588 complain_overflow_signed, /* Complain_on_overflow. */
1589 reloc_nil, /* Special_function. */
1590 "SREL64", /* Name. */
1591 TRUE, /* Partial_inplace. */
1592 MINUS_ONE, /* Source mask. */
1593 MINUS_ONE, /* Dest mask. */
1594 FALSE), /* PC rel offset. */
1596 /* Push a value on the reloc evaluation stack. */
1597 HOWTO (ALPHA_R_OP_PUSH, /* Type. */
1598 0, /* Rightshift. */
1599 0, /* Size (0 = byte, 1 = short, 2 = long). */
1600 0, /* Bitsize. */
1601 FALSE, /* PC relative. */
1602 0, /* Bitpos. */
1603 complain_overflow_dont,/* Complain_on_overflow. */
1604 reloc_nil, /* Special_function. */
1605 "OP_PUSH", /* Name. */
1606 FALSE, /* Partial_inplace. */
1607 0, /* Source mask. */
1608 0, /* Dest mask. */
1609 FALSE), /* PC rel offset. */
1611 /* Store the value from the stack at the given address. Store it in
1612 a bitfield of size r_size starting at bit position r_offset. */
1613 HOWTO (ALPHA_R_OP_STORE, /* Type. */
1614 0, /* Rightshift. */
1615 4, /* Size (0 = byte, 1 = short, 2 = long). */
1616 64, /* Bitsize. */
1617 FALSE, /* PC relative. */
1618 0, /* Bitpos. */
1619 complain_overflow_dont,/* Complain_on_overflow. */
1620 reloc_nil, /* Special_function. */
1621 "OP_STORE", /* Name. */
1622 FALSE, /* Partial_inplace. */
1623 0, /* Source mask. */
1624 MINUS_ONE, /* Dest mask. */
1625 FALSE), /* PC rel offset. */
1627 /* Subtract the reloc address from the value on the top of the
1628 relocation stack. */
1629 HOWTO (ALPHA_R_OP_PSUB, /* Type. */
1630 0, /* Rightshift. */
1631 0, /* Size (0 = byte, 1 = short, 2 = long). */
1632 0, /* Bitsize. */
1633 FALSE, /* PC relative. */
1634 0, /* Bitpos. */
1635 complain_overflow_dont,/* Complain_on_overflow. */
1636 reloc_nil, /* Special_function. */
1637 "OP_PSUB", /* Name. */
1638 FALSE, /* Partial_inplace. */
1639 0, /* Source mask. */
1640 0, /* Dest mask. */
1641 FALSE), /* PC rel offset. */
1643 /* Shift the value on the top of the relocation stack right by the
1644 given value. */
1645 HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
1646 0, /* Rightshift. */
1647 0, /* Size (0 = byte, 1 = short, 2 = long). */
1648 0, /* Bitsize. */
1649 FALSE, /* PC relative. */
1650 0, /* Bitpos. */
1651 complain_overflow_dont,/* Complain_on_overflow. */
1652 reloc_nil, /* Special_function. */
1653 "OP_PRSHIFT", /* Name. */
1654 FALSE, /* Partial_inplace. */
1655 0, /* Source mask. */
1656 0, /* Dest mask. */
1657 FALSE), /* PC rel offset. */
1659 /* Hack. Linkage is done by linker. */
1660 HOWTO (ALPHA_R_LINKAGE, /* Type. */
1661 0, /* Rightshift. */
1662 8, /* Size (0 = byte, 1 = short, 2 = long). */
1663 256, /* Bitsize. */
1664 FALSE, /* PC relative. */
1665 0, /* Bitpos. */
1666 complain_overflow_dont,/* Complain_on_overflow. */
1667 reloc_nil, /* Special_function. */
1668 "LINKAGE", /* Name. */
1669 FALSE, /* Partial_inplace. */
1670 0, /* Source mask. */
1671 0, /* Dest mask. */
1672 FALSE), /* PC rel offset. */
1674 /* A 32 bit reference to a symbol. */
1675 HOWTO (ALPHA_R_REFLONG, /* Type. */
1676 0, /* Rightshift. */
1677 2, /* Size (0 = byte, 1 = short, 2 = long). */
1678 32, /* Bitsize. */
1679 FALSE, /* PC relative. */
1680 0, /* Bitpos. */
1681 complain_overflow_bitfield, /* Complain_on_overflow. */
1682 reloc_nil, /* Special_function. */
1683 "REFLONG", /* Name. */
1684 TRUE, /* Partial_inplace. */
1685 0xffffffff, /* Source mask. */
1686 0xffffffff, /* Dest mask. */
1687 FALSE), /* PC rel offset. */
1689 /* A 64 bit reference to a procedure, written as 32 bit value. */
1690 HOWTO (ALPHA_R_CODEADDR, /* Type. */
1691 0, /* Rightshift. */
1692 4, /* Size (0 = byte, 1 = short, 2 = long). */
1693 64, /* Bitsize. */
1694 FALSE, /* PC relative. */
1695 0, /* Bitpos. */
1696 complain_overflow_signed,/* Complain_on_overflow. */
1697 reloc_nil, /* Special_function. */
1698 "CODEADDR", /* Name. */
1699 FALSE, /* Partial_inplace. */
1700 0xffffffff, /* Source mask. */
1701 0xffffffff, /* Dest mask. */
1702 FALSE), /* PC rel offset. */
1704 HOWTO (ALPHA_R_NOP, /* Type. */
1705 0, /* Rightshift. */
1706 3, /* Size (0 = byte, 1 = short, 2 = long). */
1707 0, /* Bitsize. */
1708 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
1709 because the calculations for the 3 relocations are the same.
1710 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
1711 TRUE, /* PC relative. */
1712 0, /* Bitpos. */
1713 complain_overflow_dont,/* Complain_on_overflow. */
1714 reloc_nil, /* Special_function. */
1715 "NOP", /* Name. */
1716 FALSE, /* Partial_inplace. */
1717 0xffffffff, /* Source mask. */
1718 0xffffffff, /* Dest mask. */
1719 FALSE), /* PC rel offset. */
1721 HOWTO (ALPHA_R_BSR, /* Type. */
1722 0, /* Rightshift. */
1723 3, /* Size (0 = byte, 1 = short, 2 = long). */
1724 0, /* Bitsize. */
1725 TRUE, /* PC relative. */
1726 0, /* Bitpos. */
1727 complain_overflow_dont,/* Complain_on_overflow. */
1728 reloc_nil, /* Special_function. */
1729 "BSR", /* Name. */
1730 FALSE, /* Partial_inplace. */
1731 0xffffffff, /* Source mask. */
1732 0xffffffff, /* Dest mask. */
1733 FALSE), /* PC rel offset. */
1735 HOWTO (ALPHA_R_LDA, /* Type. */
1736 0, /* Rightshift. */
1737 3, /* Size (0 = byte, 1 = short, 2 = long). */
1738 0, /* Bitsize. */
1739 FALSE, /* PC relative. */
1740 0, /* Bitpos. */
1741 complain_overflow_dont,/* Complain_on_overflow. */
1742 reloc_nil, /* Special_function. */
1743 "LDA", /* Name. */
1744 FALSE, /* Partial_inplace. */
1745 0xffffffff, /* Source mask. */
1746 0xffffffff, /* Dest mask. */
1747 FALSE), /* PC rel offset. */
1749 HOWTO (ALPHA_R_BOH, /* Type. */
1750 0, /* Rightshift. */
1751 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
1752 0, /* Bitsize. */
1753 TRUE, /* PC relative. */
1754 0, /* Bitpos. */
1755 complain_overflow_dont,/* Complain_on_overflow. */
1756 reloc_nil, /* Special_function. */
1757 "BOH", /* Name. */
1758 FALSE, /* Partial_inplace. */
1759 0xffffffff, /* Source mask. */
1760 0xffffffff, /* Dest mask. */
1761 FALSE), /* PC rel offset. */
1764 /* Return a pointer to a howto structure which, when invoked, will perform
1765 the relocation code on data from the architecture noted. */
1767 static const struct reloc_howto_struct *
1768 vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
1769 bfd_reloc_code_real_type code)
1771 int alpha_type;
1773 #if VMS_DEBUG
1774 vms_debug (1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code);
1775 #endif
1777 switch (code)
1779 case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
1780 case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
1781 case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
1782 case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
1783 case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
1784 case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
1785 case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
1786 case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
1787 case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
1788 case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
1789 case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
1790 case BFD_RELOC_ALPHA_NOP: alpha_type = ALPHA_R_NOP; break;
1791 case BFD_RELOC_ALPHA_BSR: alpha_type = ALPHA_R_BSR; break;
1792 case BFD_RELOC_ALPHA_LDA: alpha_type = ALPHA_R_LDA; break;
1793 case BFD_RELOC_ALPHA_BOH: alpha_type = ALPHA_R_BOH; break;
1794 default:
1795 (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
1796 return NULL;
1798 #if VMS_DEBUG
1799 vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
1800 #endif
1801 return & alpha_howto_table[alpha_type];
1804 static reloc_howto_type *
1805 vms_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1806 const char *r_name)
1808 unsigned int i;
1810 for (i = 0;
1811 i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
1812 i++)
1813 if (alpha_howto_table[i].name != NULL
1814 && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
1815 return &alpha_howto_table[i];
1817 return NULL;
1820 /* Part 4.7, writing an object file. */
1822 /* Set the architecture and machine type in BFD abfd to arch and mach.
1823 Find the correct pointer to a structure and insert it into the arch_info
1824 pointer. */
1826 static bfd_boolean
1827 vms_set_arch_mach (bfd * abfd,
1828 enum bfd_architecture arch ATTRIBUTE_UNUSED,
1829 unsigned long mach ATTRIBUTE_UNUSED)
1831 #if VMS_DEBUG
1832 vms_debug (1, "vms_set_arch_mach (%p, %d, %ld)\n", abfd, arch, mach);
1833 #endif
1835 if (arch != bfd_arch_alpha
1836 && arch != bfd_arch_vax
1837 && arch != bfd_arch_unknown)
1838 return FALSE;
1840 return bfd_default_set_arch_mach (abfd, arch, mach);
1843 /* Sets the contents of the section section in BFD abfd to the data starting
1844 in memory at LOCATION. The data is written to the output section starting
1845 at offset offset for count bytes.
1847 Normally TRUE is returned, else FALSE. Possible error returns are:
1848 o bfd_error_no_contents - The output section does not have the
1849 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1850 o and some more too */
1852 static bfd_boolean
1853 vms_set_section_contents (bfd * abfd,
1854 asection *section,
1855 const void * location,
1856 file_ptr offset,
1857 bfd_size_type count)
1859 #if VMS_DEBUG
1860 vms_debug (1, "vms_set_section_contents (%p, sec %s, loc %p, off %ld, count %d)\n",
1861 abfd, section->name, location, (long int)offset, (int)count);
1862 vms_debug (2, "size %d\n", (int) section->size);
1863 #endif
1864 if (count == (bfd_size_type)0)
1865 return TRUE;
1867 if (section->contents == NULL)
1868 section->contents = bfd_alloc (abfd, section->size);
1869 if (section->contents == NULL)
1870 return FALSE;
1872 memcpy (section->contents + offset, location, (size_t) count);
1873 return TRUE;
1876 /* Part 4.8, linker. */
1878 /* Get the size of the section headers. */
1880 static int
1881 vms_sizeof_headers (bfd * abfd ATTRIBUTE_UNUSED,
1882 struct bfd_link_info *info ATTRIBUTE_UNUSED)
1884 #if VMS_DEBUG
1885 vms_debug (1, "vms_sizeof_headers (%p, %s)\n", abfd, (reloc)?"True":"False");
1886 #endif
1887 return 0;
1890 /* Provides default handling of relocation effort for back ends
1891 which can't be bothered to do it efficiently. */
1893 static bfd_byte *
1894 vms_bfd_get_relocated_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
1895 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1896 struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
1897 bfd_byte *data ATTRIBUTE_UNUSED,
1898 bfd_boolean relocatable ATTRIBUTE_UNUSED,
1899 asymbol **symbols ATTRIBUTE_UNUSED)
1901 #if VMS_DEBUG
1902 vms_debug (1, "vms_bfd_get_relocated_section_contents (%p, %p, %p, %p, %s, %p)\n",
1903 abfd, link_info, link_order, data, (relocatable)?"True":"False", symbols);
1904 #endif
1905 return NULL;
1908 /* ??? */
1910 static bfd_boolean
1911 vms_bfd_relax_section (bfd * abfd ATTRIBUTE_UNUSED,
1912 asection *section ATTRIBUTE_UNUSED,
1913 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1914 bfd_boolean *again ATTRIBUTE_UNUSED)
1916 #if VMS_DEBUG
1917 vms_debug (1, "vms_bfd_relax_section (%p, %s, %p, <ret>)\n",
1918 abfd, section->name, link_info);
1919 #endif
1920 return TRUE;
1923 static bfd_boolean
1924 vms_bfd_gc_sections (bfd * abfd ATTRIBUTE_UNUSED,
1925 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1927 #if VMS_DEBUG
1928 vms_debug (1, "vms_bfd_gc_sections (%p, %p)\n", abfd, link_info);
1929 #endif
1930 return TRUE;
1933 static bfd_boolean
1934 vms_bfd_merge_sections (bfd * abfd ATTRIBUTE_UNUSED,
1935 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1937 #if VMS_DEBUG
1938 vms_debug (1, "vms_bfd_merge_sections (%p, %p)\n", abfd, link_info);
1939 #endif
1940 return TRUE;
1943 /* Create a hash table for the linker. Different backends store
1944 different information in this table. */
1946 static struct bfd_link_hash_table *
1947 vms_bfd_link_hash_table_create (bfd * abfd ATTRIBUTE_UNUSED)
1949 #if VMS_DEBUG
1950 vms_debug (1, "vms_bfd_link_hash_table_create (%p)\n", abfd);
1951 #endif
1952 return NULL;
1955 /* Free a linker hash table. */
1957 static void
1958 vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED)
1960 #if VMS_DEBUG
1961 vms_debug (1, "vms_bfd_link_hash_table_free (%p)\n", abfd);
1962 #endif
1965 /* Add symbols from this object file into the hash table. */
1967 static bfd_boolean
1968 vms_bfd_link_add_symbols (bfd * abfd ATTRIBUTE_UNUSED,
1969 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1971 #if VMS_DEBUG
1972 vms_debug (1, "vms_bfd_link_add_symbols (%p, %p)\n", abfd, link_info);
1973 #endif
1974 return FALSE;
1977 /* Do a link based on the link_order structures attached to each
1978 section of the BFD. */
1980 static bfd_boolean
1981 vms_bfd_final_link (bfd * abfd ATTRIBUTE_UNUSED,
1982 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1984 #if VMS_DEBUG
1985 vms_debug (1, "vms_bfd_final_link (%p, %p)\n", abfd, link_info);
1986 #endif
1987 return TRUE;
1990 /* Should this section be split up into smaller pieces during linking. */
1992 static bfd_boolean
1993 vms_bfd_link_split_section (bfd * abfd ATTRIBUTE_UNUSED,
1994 asection *section ATTRIBUTE_UNUSED)
1996 #if VMS_DEBUG
1997 vms_debug (1, "vms_bfd_link_split_section (%p, %s)\n", abfd, section->name);
1998 #endif
1999 return FALSE;
2002 /* Part 4.9, dynamic symbols and relocations. */
2004 /* Get the amount of memory required to hold the dynamic symbols. */
2006 static long
2007 vms_get_dynamic_symtab_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
2009 #if VMS_DEBUG
2010 vms_debug (1, "vms_get_dynamic_symtab_upper_bound (%p)\n", abfd);
2011 #endif
2012 return 0L;
2015 static bfd_boolean
2016 vms_bfd_print_private_bfd_data (bfd * abfd ATTRIBUTE_UNUSED,
2017 void *file ATTRIBUTE_UNUSED)
2019 #if VMS_DEBUG
2020 vms_debug (1, "vms_bfd_print_private_bfd_data (%p)\n", abfd);
2021 #endif
2022 return FALSE;
2025 /* Read in the dynamic symbols. */
2027 static long
2028 vms_canonicalize_dynamic_symtab (bfd * abfd ATTRIBUTE_UNUSED,
2029 asymbol **symbols ATTRIBUTE_UNUSED)
2031 #if VMS_DEBUG
2032 vms_debug (1, "vms_canonicalize_dynamic_symtab (%p, <ret>)\n", abfd);
2033 #endif
2034 return 0L;
2037 /* Get the amount of memory required to hold the dynamic relocs. */
2039 static long
2040 vms_get_dynamic_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
2042 #if VMS_DEBUG
2043 vms_debug (1, "vms_get_dynamic_reloc_upper_bound (%p)\n", abfd);
2044 #endif
2045 return 0L;
2048 /* Read in the dynamic relocs. */
2050 static long
2051 vms_canonicalize_dynamic_reloc (bfd * abfd ATTRIBUTE_UNUSED,
2052 arelent **arel ATTRIBUTE_UNUSED,
2053 asymbol **symbols ATTRIBUTE_UNUSED)
2055 #if VMS_DEBUG
2056 vms_debug (1, "vms_canonicalize_dynamic_reloc (%p)\n", abfd);
2057 #endif
2058 return 0L;
2061 const bfd_target vms_alpha_vec =
2063 "vms-alpha", /* Name. */
2064 bfd_target_evax_flavour,
2065 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
2066 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
2068 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
2069 | WP_TEXT | D_PAGED), /* Object flags. */
2070 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
2071 | SEC_READONLY | SEC_CODE | SEC_DATA
2072 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
2073 0, /* symbol_leading_char. */
2074 ' ', /* ar_pad_char. */
2075 15, /* ar_max_namelen. */
2076 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2077 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2078 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
2079 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2080 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2081 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
2083 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
2084 vms_archive_p, _bfd_dummy_target},
2085 {bfd_false, vms_mkobject, /* bfd_set_format. */
2086 _bfd_generic_mkarchive, bfd_false},
2087 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
2088 _bfd_write_archive_contents, bfd_false},
2090 BFD_JUMP_TABLE_GENERIC (vms),
2091 BFD_JUMP_TABLE_COPY (vms),
2092 BFD_JUMP_TABLE_CORE (vms),
2093 BFD_JUMP_TABLE_ARCHIVE (vms),
2094 BFD_JUMP_TABLE_SYMBOLS (vms),
2095 BFD_JUMP_TABLE_RELOCS (vms),
2096 BFD_JUMP_TABLE_WRITE (vms),
2097 BFD_JUMP_TABLE_LINK (vms),
2098 BFD_JUMP_TABLE_DYNAMIC (vms),
2100 NULL,
2102 (PTR) 0
2105 const bfd_target vms_vax_vec =
2107 "vms-vax", /* Name. */
2108 bfd_target_ovax_flavour,
2109 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
2110 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
2112 (HAS_RELOC | HAS_SYMS /* Object flags. */
2113 | WP_TEXT | D_PAGED
2114 | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
2116 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
2117 | SEC_READONLY | SEC_CODE | SEC_DATA
2118 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
2119 0, /* symbol_leading_char */
2120 ' ', /* ar_pad_char */
2121 15, /* ar_max_namelen */
2122 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2123 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2124 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
2125 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2126 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2127 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs. */
2129 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
2130 vms_archive_p, _bfd_dummy_target},
2131 {bfd_false, vms_mkobject, /* bfd_set_format. */
2132 _bfd_generic_mkarchive, bfd_false},
2133 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
2134 _bfd_write_archive_contents, bfd_false},
2136 BFD_JUMP_TABLE_GENERIC (vms),
2137 BFD_JUMP_TABLE_COPY (vms),
2138 BFD_JUMP_TABLE_CORE (vms),
2139 BFD_JUMP_TABLE_ARCHIVE (vms),
2140 BFD_JUMP_TABLE_SYMBOLS (vms),
2141 BFD_JUMP_TABLE_RELOCS (vms),
2142 BFD_JUMP_TABLE_WRITE (vms),
2143 BFD_JUMP_TABLE_LINK (vms),
2144 BFD_JUMP_TABLE_DYNAMIC (vms),
2146 NULL,
2148 (PTR) 0