* ppc-linux-nat.c (have_ptrace_getsetregs): New variable.
[gdb/SamB.git] / bfd / vms.c
blobac03480278d3875be97538bebf4e193f9f70a870
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_define_common_symbol bfd_generic_define_common_symbol
148 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
149 #define vms_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
152 #ifdef VMS_DEBUG
153 /* Cause debug info to be emitted for the structure. */
154 struct vms_private_data_struct _vms_private_data_struct_dummy;
155 struct vms_section_data_struct _vms_section_data_struct_dummy;
156 #endif
158 extern const bfd_target vms_vax_vec;
159 extern const bfd_target vms_alpha_vec;
161 /* Initialize private data */
162 static bfd_boolean
163 vms_initialize (bfd * abfd)
165 bfd_size_type amt;
167 bfd_set_start_address (abfd, (bfd_vma) -1);
169 amt = sizeof (struct vms_private_data_struct);
170 abfd->tdata.any = bfd_zalloc (abfd, amt);
171 if (abfd->tdata.any == NULL)
172 return FALSE;
174 if (bfd_get_flavour (abfd) == bfd_target_ovax_flavour)
175 PRIV (is_vax) = TRUE;
177 PRIV (file_format) = FF_UNKNOWN;
179 amt = sizeof (struct stack_struct) * STACKSIZE;
180 PRIV (stack) = bfd_alloc (abfd, amt);
181 if (PRIV (stack) == NULL)
182 goto error_ret1;
184 amt = sizeof (struct bfd_hash_table);
185 PRIV (vms_symbol_table) = bfd_alloc (abfd, amt);
186 if (PRIV (vms_symbol_table) == NULL)
187 goto error_ret1;
189 if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc,
190 sizeof (vms_symbol_entry)))
191 goto error_ret1;
193 amt = MAX_OUTREC_SIZE;
194 PRIV (output_buf) = bfd_alloc (abfd, amt);
195 if (PRIV (output_buf) == NULL)
196 goto error_ret2;
198 PRIV (length_pos) = 2;
200 return TRUE;
202 error_ret2:
203 bfd_hash_table_free (PRIV (vms_symbol_table));
204 error_ret1:
205 bfd_release (abfd, abfd->tdata.any);
206 abfd->tdata.any = NULL;
207 return FALSE;
210 struct pair
212 unsigned int section_count;
213 asection **sections;
216 /* Fill symbol->section with section pointer.
218 symbol->section is filled with the section index for defined symbols
219 during reading the GSD/EGSD section. But we need the pointer to the
220 bfd section later.
222 It has the correct value for referenced (undefined section) symbols.
224 Called from bfd_hash_traverse in vms_fixup_sections. */
226 static bfd_boolean
227 fill_section_ptr (struct bfd_hash_entry *entry, void *sections)
229 asymbol *sym = ((vms_symbol_entry *)entry)->symbol;
230 struct pair *data = (struct pair *)sections;
231 unsigned long sec = (unsigned long)sym->section;
233 #if VMS_DEBUG
234 vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
235 #endif
237 if (sec < data->section_count)
239 sym->section = data->sections[sec];
241 if (strcmp (sym->name, sym->section->name) == 0)
242 sym->flags |= BSF_SECTION_SYM;
244 else if (sec == (unsigned long)-1)
245 sym->section = &bfd_und_section;
247 return TRUE;
250 /* Fixup section pointers in symbols. */
251 static bfd_boolean
252 vms_fixup_sections (bfd * abfd)
254 struct pair data;
256 if (PRIV (fixup_done))
257 return TRUE;
259 data.section_count = PRIV (section_count);
260 data.sections = PRIV (sections);
261 bfd_hash_traverse (PRIV (vms_symbol_table), fill_section_ptr, &data);
263 PRIV (fixup_done) = TRUE;
264 return TRUE;
267 /* Slurp an ordered set of VMS object records. */
269 _bfd_vms_slurp_object_records (bfd * abfd)
271 int err, new_type, type = -1;
275 #if VMS_DEBUG
276 vms_debug (7, "reading at %08lx\n", bfd_tell (abfd));
277 #endif
278 new_type = _bfd_vms_get_object_record (abfd);
279 if (new_type < 0)
281 #if VMS_DEBUG
282 vms_debug (2, "next_record failed\n");
283 #endif
284 return -1;
287 if (type == EOBJ_S_C_EGSD && new_type != EOBJ_S_C_EGSD)
289 if (! vms_fixup_sections (abfd))
291 #if VMS_DEBUG
292 vms_debug (2, "vms_fixup_sections failed\n");
293 #endif
294 return -1;
298 type = new_type;
300 switch (type)
302 case OBJ_S_C_HDR:
303 case EOBJ_S_C_EMH:
304 err = _bfd_vms_slurp_hdr (abfd, type);
305 break;
306 case OBJ_S_C_EOM:
307 case OBJ_S_C_EOMW:
308 case EOBJ_S_C_EEOM:
309 err = _bfd_vms_slurp_eom (abfd, type);
310 break;
311 case OBJ_S_C_GSD:
312 case EOBJ_S_C_EGSD:
313 err = _bfd_vms_slurp_gsd (abfd, type);
314 break;
315 case OBJ_S_C_TIR:
316 case EOBJ_S_C_ETIR:
317 err = _bfd_vms_slurp_tir (abfd, type);
318 break;
319 case OBJ_S_C_DBG:
320 case EOBJ_S_C_EDBG:
321 err = _bfd_vms_slurp_dbg (abfd, type);
322 PRIV (dst_ptr_end) = PRIV (image_ptr);
323 break;
324 case OBJ_S_C_TBT:
325 case EOBJ_S_C_ETBT:
326 err = _bfd_vms_slurp_tbt (abfd, type);
327 PRIV (dst_ptr_end) = PRIV (image_ptr);
328 break;
329 case OBJ_S_C_LNK:
330 err = _bfd_vms_slurp_lnk (abfd, type);
331 break;
332 default:
333 err = -1;
335 if (err != 0)
337 #if VMS_DEBUG
338 vms_debug (2, "slurp type %d failed with %d\n", type, err);
339 #endif
340 return err;
343 while (type != EOBJ_S_C_EEOM && type != OBJ_S_C_EOM && type != OBJ_S_C_EOMW);
345 return 0;
348 /* Slurp a VMS module and return an error status. */
350 static int
351 vms_slurp_module (bfd *abfd)
353 int type, err;
355 if (PRIV (is_vax))
356 type = PRIV (vms_rec)[0];
357 else
358 type = bfd_getl16 (PRIV (vms_rec));
360 err = _bfd_vms_slurp_hdr (abfd, type);
361 if (err != 0)
363 bfd_set_error (bfd_error_wrong_format);
364 return err;
367 return _bfd_vms_slurp_object_records (abfd);
370 /* Slurp a VMS image and return an error status. */
372 static int
373 vms_slurp_image (bfd *abfd)
375 unsigned int isd_offset, ihs_offset;
376 int err;
378 err = _bfd_vms_slurp_ihd (abfd, &isd_offset, &ihs_offset);
379 if (err != 0)
381 bfd_set_error (bfd_error_wrong_format);
382 return err;
385 err = _bfd_vms_slurp_isd (abfd, isd_offset);
386 if (err != 0)
388 bfd_set_error (bfd_error_wrong_format);
389 return err;
392 return _bfd_vms_slurp_ihs (abfd, ihs_offset);
395 /* Check the format for a file being read.
396 Return a (bfd_target *) if it's an object file or zero if not. */
398 static const struct bfd_target *
399 vms_object_p (bfd *abfd)
401 const struct bfd_target *target_vector;
402 const bfd_arch_info_type *arch;
403 PTR tdata_save = abfd->tdata.any;
404 bfd_vma saddr_save = bfd_get_start_address (abfd);
405 int err = 0;
407 #if VMS_DEBUG
408 vms_debug (1, "vms_object_p(%p)\n", abfd);
409 #endif
411 if (!vms_initialize (abfd))
412 goto error_ret;
414 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
415 goto err_wrong_format;
417 switch (_bfd_vms_get_first_record (abfd))
419 case FT_UNKNOWN:
420 default:
421 err = -1;
422 break;
424 case FT_MODULE:
425 err = vms_slurp_module (abfd);
426 break;
428 case FT_IMAGE:
429 err = vms_slurp_image (abfd);
430 break;
433 if (err != 0)
434 goto err_wrong_format;
436 if (PRIV (is_vax))
438 if (! vms_fixup_sections (abfd))
440 #if VMS_DEBUG
441 vms_debug (2, "vms_fixup_sections failed\n");
442 #endif
443 goto err_wrong_format;
446 target_vector = &vms_vax_vec;
447 arch = bfd_scan_arch ("vax");
449 #if VMS_DEBUG
450 vms_debug (2, "arch is vax\n");
451 #endif
453 else
455 /* Set arch_info to alpha. */
456 target_vector = &vms_alpha_vec;
457 arch = bfd_scan_arch ("alpha");
458 #if VMS_DEBUG
459 vms_debug (2, "arch is alpha\n");
460 #endif
463 abfd->arch_info = arch;
464 return target_vector;
466 err_wrong_format:
467 bfd_set_error (bfd_error_wrong_format);
469 error_ret:
470 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
471 bfd_release (abfd, abfd->tdata.any);
472 abfd->tdata.any = tdata_save;
473 bfd_set_start_address (abfd, saddr_save);
474 return NULL;
477 /* Check the format for a file being read.
478 Return a (bfd_target *) if it's an archive file or zero. */
480 static const struct bfd_target *
481 vms_archive_p (bfd * abfd ATTRIBUTE_UNUSED)
483 #if VMS_DEBUG
484 vms_debug (1, "vms_archive_p (%p)\n", abfd);
485 #endif
487 return NULL;
490 /* Set the format of a file being written. */
492 static bfd_boolean
493 vms_mkobject (bfd * abfd)
495 const bfd_arch_info_type *arch;
497 #if VMS_DEBUG
498 vms_debug (1, "vms_mkobject (%p)\n", abfd);
499 #endif
501 if (!vms_initialize (abfd))
502 return FALSE;
504 if (PRIV (is_vax))
505 arch = bfd_scan_arch ("vax");
506 else
507 arch = bfd_scan_arch ("alpha");
509 if (arch == 0)
511 bfd_set_error(bfd_error_wrong_format);
512 return FALSE;
515 abfd->arch_info = arch;
516 return TRUE;
519 /* Write cached information into a file being written, at bfd_close. */
521 static bfd_boolean
522 vms_write_object_contents (bfd * abfd)
524 #if VMS_DEBUG
525 vms_debug (1, "vms_write_object_contents (%p)\n", abfd);
526 #endif
528 if (abfd->section_count > 0) /* we have sections */
530 if (PRIV (is_vax))
532 if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0)
533 return FALSE;
534 if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0)
535 return FALSE;
536 if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0)
537 return FALSE;
538 if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0)
539 return FALSE;
540 if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0)
541 return FALSE;
542 if (abfd->section_count > 255)
544 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
545 return FALSE;
547 else
549 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
550 return FALSE;
553 else
555 if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0)
556 return FALSE;
557 if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0)
558 return FALSE;
559 if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0)
560 return FALSE;
561 if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0)
562 return FALSE;
563 if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0)
564 return FALSE;
565 if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0)
566 return FALSE;
569 return TRUE;
572 /* 4.1, generic. */
574 /* Free the reloc buffer for the specified section. */
576 static void
577 free_reloc_stream (bfd *abfd ATTRIBUTE_UNUSED, asection *section,
578 void *data ATTRIBUTE_UNUSED)
580 if (vms_section_data (section)->reloc_stream)
581 free (vms_section_data (section)->reloc_stream);
584 #ifdef VMS
585 /* Convert the file to variable record length format. This is done
586 using undocumented system call sys$modify().
587 Pure VMS version. */
589 static void
590 vms_convert_to_var (char *vms_filename)
592 struct FAB fab = cc$rms_fab;
594 fab.fab$l_fna = vms_filename;
595 fab.fab$b_fns = strlen (vms_filename);
596 fab.fab$b_fac = FAB$M_PUT;
597 fab.fab$l_fop = FAB$M_ESC;
598 fab.fab$l_ctx = RME$C_SETRFM;
600 sys$open (&fab);
602 fab.fab$b_rfm = FAB$C_VAR;
604 sys$modify (&fab);
605 sys$close (&fab);
608 static int
609 vms_convert_to_var_1 (char *filename, int type)
611 if (type != DECC$K_FILE)
612 return FALSE;
613 vms_convert_to_var (filename);
614 return TRUE;
617 /* Convert the file to variable record length format. This is done
618 using undocumented system call sys$modify().
619 Unix filename version. */
621 static int
622 vms_convert_to_var_unix_filename (const char *unix_filename)
624 if (decc$to_vms (unix_filename, &vms_convert_to_var_1, 0, 1) != 1)
625 return FALSE;
626 return TRUE;
628 #endif /* VMS */
630 /* Called when the BFD is being closed to do any necessary cleanup. */
632 static bfd_boolean
633 vms_close_and_cleanup (bfd * abfd)
635 #if VMS_DEBUG
636 vms_debug (1, "vms_close_and_cleanup (%p)\n", abfd);
637 #endif
638 if (abfd == NULL || abfd->tdata.any == NULL)
639 return TRUE;
641 if (PRIV (vms_buf) != NULL)
642 free (PRIV (vms_buf));
644 if (PRIV (sections) != NULL)
645 free (PRIV (sections));
647 if (PRIV (vms_symbol_table))
648 bfd_hash_table_free (PRIV (vms_symbol_table));
650 bfd_map_over_sections (abfd, free_reloc_stream, NULL);
652 bfd_release (abfd, abfd->tdata.any);
653 abfd->tdata.any = NULL;
655 #ifdef VMS
656 if (abfd->direction == write_direction)
658 /* Last step on VMS is to convert the file to variable record length
659 format. */
660 if (bfd_cache_close (abfd) != TRUE)
661 return FALSE;
662 if (vms_convert_to_var_unix_filename (abfd->filename) != TRUE)
663 return FALSE;
665 #endif
667 return TRUE;
670 /* Ask the BFD to free all cached information. */
672 static bfd_boolean
673 vms_bfd_free_cached_info (bfd * abfd ATTRIBUTE_UNUSED)
675 #if VMS_DEBUG
676 vms_debug (1, "vms_bfd_free_cached_info (%p)\n", abfd);
677 #endif
678 return TRUE;
681 /* Called when a new section is created. */
683 static bfd_boolean
684 vms_new_section_hook (bfd * abfd, asection *section)
686 bfd_size_type amt;
688 /* Count hasn't been incremented yet. */
689 unsigned int section_count = abfd->section_count + 1;
691 #if VMS_DEBUG
692 vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
693 abfd, section->index, section->name, section_count);
694 #endif
696 bfd_set_section_alignment (abfd, section, 0);
698 if (section_count > PRIV (section_count))
700 bfd_size_type amt = section_count;
701 amt *= sizeof (asection *);
702 PRIV (sections) = bfd_realloc_or_free (PRIV (sections), amt);
703 if (PRIV (sections) == NULL)
704 return FALSE;
705 PRIV (section_count) = section_count;
708 #if VMS_DEBUG
709 vms_debug (6, "section_count: %d\n", PRIV (section_count));
710 #endif
712 PRIV (sections)[section->index] = section;
714 #if VMS_DEBUG
715 vms_debug (7, "%d: %s\n", section->index, section->name);
716 #endif
718 amt = sizeof (struct vms_section_data_struct);
719 section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
720 if (section->used_by_bfd == NULL)
721 return FALSE;
723 return _bfd_generic_new_section_hook (abfd, section);
726 /* Read the contents of a section.
727 buf points to a buffer of buf_size bytes to be filled with
728 section data (starting at offset into section) */
730 static bfd_boolean
731 vms_get_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
732 asection *section ATTRIBUTE_UNUSED,
733 void * buf ATTRIBUTE_UNUSED,
734 file_ptr offset ATTRIBUTE_UNUSED,
735 bfd_size_type buf_size ATTRIBUTE_UNUSED)
737 bfd_size_type size = section->size;
739 #if VMS_DEBUG
740 vms_debug (1, "vms_get_section_contents (%p, %s, %p, off %ld, size %d)\n",
741 abfd, section->name, buf, offset, (int)buf_size);
742 #endif
744 if (section->contents)
745 abort ();
747 section->contents = (unsigned char *) bfd_malloc (size);
749 if (section->contents == NULL)
751 bfd_set_error (bfd_error_no_memory);
752 return FALSE;
755 if (bfd_seek (abfd, section->filepos, SEEK_SET))
757 bfd_set_error (bfd_error_file_truncated);
758 return FALSE;
761 if (bfd_bread (section->contents, size, abfd) != size)
763 bfd_set_error (bfd_error_file_truncated);
764 return FALSE;
767 section->flags |= SEC_IN_MEMORY;
769 if (buf)
770 memcpy (buf, section->contents + offset, (size_t) buf_size);
772 return TRUE;
775 /* Read the contents of a section.
776 buf points to a buffer of buf_size bytes to be filled with
777 section data (starting at offset into section). */
779 static bfd_boolean
780 vms_get_section_contents_in_window (bfd * abfd ATTRIBUTE_UNUSED,
781 asection *section ATTRIBUTE_UNUSED,
782 bfd_window *w ATTRIBUTE_UNUSED,
783 file_ptr offset ATTRIBUTE_UNUSED,
784 bfd_size_type count ATTRIBUTE_UNUSED)
786 #if VMS_DEBUG
787 vms_debug (1, "vms_get_section_contents_in_window (%p, %s, %p, off %ld, count %d)\n",
788 abfd, section->name, w, offset, (int)count);
789 #endif
791 /* Shouldn't be called, since all sections are IN_MEMORY. */
792 return FALSE;
795 /* Part 4.2, copy private data. */
797 /* Called to copy BFD general private data from one object file
798 to another. */
800 static bfd_boolean
801 vms_bfd_copy_private_bfd_data (bfd *src ATTRIBUTE_UNUSED,
802 bfd *dest ATTRIBUTE_UNUSED)
804 #if VMS_DEBUG
805 vms_debug (1, "vms_bfd_copy_private_bfd_data (%p, %p)\n", src, dest);
806 #endif
807 return TRUE;
810 /* Merge private BFD information from the BFD @var{ibfd} to the
811 the output file BFD @var{obfd} when linking. Return <<TRUE>>
812 on success, <<FALSE>> on error. Possible error returns are:
814 o <<bfd_error_no_memory>> -
815 Not enough memory exists to create private data for @var{obfd}. */
817 static bfd_boolean
818 vms_bfd_merge_private_bfd_data (bfd * ibfd ATTRIBUTE_UNUSED,
819 bfd * obfd ATTRIBUTE_UNUSED)
821 #if VMS_DEBUG
822 vms_debug (1,"vms_bfd_merge_private_bfd_data (%p, %p)\n", ibfd, obfd);
823 #endif
824 return TRUE;
827 /* Set private BFD flag information in the BFD @var{abfd}.
828 Return <<TRUE>> on success, <<FALSE>> on error. Possible error
829 returns are:
831 o <<bfd_error_no_memory>> -
832 Not enough memory exists to create private data for @var{obfd}. */
834 static bfd_boolean
835 vms_bfd_set_private_flags (bfd * abfd ATTRIBUTE_UNUSED,
836 flagword flags ATTRIBUTE_UNUSED)
838 #if VMS_DEBUG
839 vms_debug (1,"vms_bfd_set_private_flags (%p, %lx)\n", abfd, (long)flags);
840 #endif
841 return TRUE;
844 /* Called to copy BFD private section data from one object file
845 to another. */
847 static bfd_boolean
848 vms_bfd_copy_private_section_data (bfd *srcbfd ATTRIBUTE_UNUSED,
849 asection *srcsec ATTRIBUTE_UNUSED,
850 bfd *dstbfd ATTRIBUTE_UNUSED,
851 asection *dstsec ATTRIBUTE_UNUSED)
853 #if VMS_DEBUG
854 vms_debug (1, "vms_bfd_copy_private_section_data (%p, %s, %p, %s)\n",
855 srcbfd, srcsec->name, dstbfd, dstsec->name);
856 #endif
857 return TRUE;
860 /* Called to copy BFD private symbol data from one object file
861 to another. */
863 static bfd_boolean
864 vms_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED,
865 asymbol *isym ATTRIBUTE_UNUSED,
866 bfd *obfd ATTRIBUTE_UNUSED,
867 asymbol *osym ATTRIBUTE_UNUSED)
869 #if VMS_DEBUG
870 vms_debug (1, "vms_bfd_copy_private_symbol_data (%p, %s, %p, %s)\n",
871 ibfd, isym->name, obfd, osym->name);
872 #endif
873 return TRUE;
876 /* Part 4.3, core file. */
878 /* Return a read-only string explaining which program was running
879 when it failed and produced the core file abfd. */
881 static char *
882 vms_core_file_failing_command (bfd * abfd ATTRIBUTE_UNUSED)
884 #if VMS_DEBUG
885 vms_debug (1, "vms_core_file_failing_command (%p)\n", abfd);
886 #endif
887 return NULL;
890 /* Returns the signal number which caused the core dump which
891 generated the file the BFD abfd is attached to. */
893 static int
894 vms_core_file_failing_signal (bfd * abfd ATTRIBUTE_UNUSED)
896 #if VMS_DEBUG
897 vms_debug (1, "vms_core_file_failing_signal (%p)\n", abfd);
898 #endif
899 return 0;
902 /* Return TRUE if the core file attached to core_bfd was generated
903 by a run of the executable file attached to exec_bfd, FALSE otherwise. */
905 static bfd_boolean
906 vms_core_file_matches_executable_p (bfd * abfd ATTRIBUTE_UNUSED,
907 bfd *bbfd ATTRIBUTE_UNUSED)
909 #if VMS_DEBUG
910 vms_debug (1, "vms_core_file_matches_executable_p (%p, %p)\n", abfd, bbfd);
911 #endif
912 return FALSE;
915 /* Part 4.4, archive. */
917 /* ??? do something with an archive map.
918 Return FALSE on error, TRUE otherwise. */
920 static bfd_boolean
921 vms_slurp_armap (bfd * abfd ATTRIBUTE_UNUSED)
923 #if VMS_DEBUG
924 vms_debug (1, "vms_slurp_armap (%p)\n", abfd);
925 #endif
926 return FALSE;
929 /* ??? do something with an extended name table.
930 Return FALSE on error, TRUE otherwise. */
932 static bfd_boolean
933 vms_slurp_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED)
935 #if VMS_DEBUG
936 vms_debug (1, "vms_slurp_extended_name_table (%p)\n", abfd);
937 #endif
938 return FALSE;
941 /* ??? do something with an extended name table.
942 Return FALSE on error, TRUE otherwise. */
944 static bfd_boolean
945 vms_construct_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED,
946 char **tabloc ATTRIBUTE_UNUSED,
947 bfd_size_type *tablen ATTRIBUTE_UNUSED,
948 const char **name ATTRIBUTE_UNUSED)
950 #if VMS_DEBUG
951 vms_debug (1, "vms_construct_extended_name_table (%p)\n", abfd);
952 #endif
953 return FALSE;
956 /* Truncate the name of an archive to match system-dependent restrictions. */
958 static void
959 vms_truncate_arname (bfd * abfd ATTRIBUTE_UNUSED,
960 const char *pathname ATTRIBUTE_UNUSED,
961 char *arhdr ATTRIBUTE_UNUSED)
963 #if VMS_DEBUG
964 vms_debug (1, "vms_truncate_arname (%p, %s, %s)\n", abfd, pathname, arhdr);
965 #endif
968 /* ??? write archive map. */
970 static bfd_boolean
971 vms_write_armap (bfd *arch ATTRIBUTE_UNUSED,
972 unsigned int elength ATTRIBUTE_UNUSED,
973 struct orl *map ATTRIBUTE_UNUSED,
974 unsigned int orl_count ATTRIBUTE_UNUSED,
975 int stridx ATTRIBUTE_UNUSED)
977 #if VMS_DEBUG
978 vms_debug (1, "vms_write_armap (%p, %d, %p, %d %d)\n",
979 arch, elength, map, orl_count, stridx);
980 #endif
981 return TRUE;
984 /* Read archive header ??? */
986 static void *
987 vms_read_ar_hdr (bfd * abfd ATTRIBUTE_UNUSED)
989 #if VMS_DEBUG
990 vms_debug (1, "vms_read_ar_hdr (%p)\n", abfd);
991 #endif
992 return NULL;
995 /* Provided a BFD, @var{archive}, containing an archive and NULL, open
996 an input BFD on the first contained element and returns that.
997 Subsequent calls should pass the archive and the previous return value
998 to return a created BFD to the next contained element.
999 NULL is returned when there are no more. */
1001 static bfd *
1002 vms_openr_next_archived_file (bfd *arch ATTRIBUTE_UNUSED,
1003 bfd *prev ATTRIBUTE_UNUSED)
1005 #if VMS_DEBUG
1006 vms_debug (1, "vms_openr_next_archived_file (%p, %p)\n", arch, prev);
1007 #endif
1008 return NULL;
1011 /* Return the BFD which is referenced by the symbol in ABFD indexed by
1012 INDEX. INDEX should have been returned by bfd_get_next_mapent. */
1014 static bfd *
1015 vms_get_elt_at_index (bfd * abfd, symindex index)
1017 #if VMS_DEBUG
1018 vms_debug (1, "vms_get_elt_at_index (%p, %p)\n", abfd, index);
1019 #endif
1020 return _bfd_generic_get_elt_at_index (abfd, index);
1023 /* ???
1024 -> bfd_generic_stat_arch_elt. */
1026 static int
1027 vms_generic_stat_arch_elt (bfd * abfd, struct stat *st)
1029 #if VMS_DEBUG
1030 vms_debug (1, "vms_generic_stat_arch_elt (%p, %p)\n", abfd, st);
1031 #endif
1032 return bfd_generic_stat_arch_elt (abfd, st);
1035 /* This is a new function in bfd 2.5. */
1037 static bfd_boolean
1038 vms_update_armap_timestamp (bfd * abfd ATTRIBUTE_UNUSED)
1040 #if VMS_DEBUG
1041 vms_debug (1, "vms_update_armap_timestamp (%p)\n", abfd);
1042 #endif
1043 return TRUE;
1046 /* Part 4.5, symbols. */
1048 /* Return the number of bytes required to store a vector of pointers
1049 to asymbols for all the symbols in the BFD abfd, including a
1050 terminal NULL pointer. If there are no symbols in the BFD,
1051 then return 0. If an error occurs, return -1. */
1053 static long
1054 vms_get_symtab_upper_bound (bfd * abfd)
1056 #if VMS_DEBUG
1057 vms_debug (1, "vms_get_symtab_upper_bound (%p), %d symbols\n", abfd, PRIV (gsd_sym_count));
1058 #endif
1059 return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *);
1062 /* Copy symbols from hash table to symbol vector
1064 called from bfd_hash_traverse in vms_canonicalize_symtab
1065 init counter to 0 if entry == 0. */
1067 static bfd_boolean
1068 copy_symbols (struct bfd_hash_entry *entry, void * arg)
1070 bfd * abfd = (bfd *) arg;
1072 if (entry == NULL) /* Init counter. */
1073 PRIV (symnum) = 0;
1074 else /* Fill vector, inc counter. */
1075 PRIV (symcache)[PRIV (symnum)++] = ((vms_symbol_entry *)entry)->symbol;
1077 return TRUE;
1080 /* Read the symbols from the BFD abfd, and fills in the vector
1081 location with pointers to the symbols and a trailing NULL.
1083 Return number of symbols read. */
1085 static long
1086 vms_canonicalize_symtab (bfd * abfd, asymbol **symbols)
1088 #if VMS_DEBUG
1089 vms_debug (1, "vms_canonicalize_symtab (%p, <ret>)\n", abfd);
1090 #endif
1092 /* Init counter. */
1093 copy_symbols (NULL, abfd);
1095 /* Traverse table and fill symbols vector. */
1096 PRIV (symcache) = symbols;
1097 bfd_hash_traverse (PRIV (vms_symbol_table), copy_symbols, abfd);
1099 symbols[PRIV (gsd_sym_count)] = NULL;
1101 return PRIV (gsd_sym_count);
1104 /* Print symbol to file according to how. how is one of
1105 bfd_print_symbol_name just print the name
1106 bfd_print_symbol_more print more (???)
1107 bfd_print_symbol_all print all we know, which is not much right now :-). */
1109 static void
1110 vms_print_symbol (bfd * abfd,
1111 void * file,
1112 asymbol *symbol,
1113 bfd_print_symbol_type how)
1115 #if VMS_DEBUG
1116 vms_debug (1, "vms_print_symbol (%p, %p, %p, %d)\n", abfd, file, symbol, how);
1117 #endif
1119 switch (how)
1121 case bfd_print_symbol_name:
1122 case bfd_print_symbol_more:
1123 fprintf ((FILE *)file," %s", symbol->name);
1124 break;
1126 case bfd_print_symbol_all:
1128 const char *section_name = symbol->section->name;
1130 bfd_print_symbol_vandf (abfd, file, symbol);
1132 fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
1134 break;
1138 /* Return information about symbol in ret.
1140 fill type, value and name
1141 type:
1142 A absolute
1143 B bss segment symbol
1144 C common symbol
1145 D data segment symbol
1146 f filename
1147 t a static function symbol
1148 T text segment symbol
1149 U undefined
1150 - debug. */
1152 static void
1153 vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
1154 asymbol *symbol,
1155 symbol_info *ret)
1157 asection *sec;
1159 #if VMS_DEBUG
1160 vms_debug (1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret);
1161 #endif
1163 sec = symbol->section;
1165 if (ret == NULL)
1166 return;
1168 if (sec == 0)
1169 ret->type = 'U';
1170 else if (bfd_is_com_section (sec))
1171 ret->type = 'C';
1172 else if (bfd_is_abs_section (sec))
1173 ret->type = 'A';
1174 else if (bfd_is_und_section (sec))
1175 ret->type = 'U';
1176 else if (bfd_is_ind_section (sec))
1177 ret->type = 'I';
1178 else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
1179 ret->type = 'T';
1180 else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
1181 ret->type = 'D';
1182 else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
1183 ret->type = 'B';
1184 else
1185 ret->type = '-';
1187 if (ret->type != 'U')
1188 ret->value = symbol->value + symbol->section->vma;
1189 else
1190 ret->value = 0;
1191 ret->name = symbol->name;
1194 /* Return TRUE if the given symbol sym in the BFD abfd is
1195 a compiler generated local label, else return FALSE. */
1197 static bfd_boolean
1198 vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
1199 const char *name)
1201 #if VMS_DEBUG
1202 vms_debug (1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd, name);
1203 #endif
1204 return name[0] == '$';
1207 /* Get source line number for symbol. */
1209 static alent *
1210 vms_get_lineno (bfd * abfd ATTRIBUTE_UNUSED,
1211 asymbol *symbol ATTRIBUTE_UNUSED)
1213 #if VMS_DEBUG
1214 vms_debug (1, "vms_get_lineno (%p, %p)\n", abfd, symbol);
1215 #endif
1216 return NULL;
1219 /* Provided a BFD, a section and an offset into the section, calculate and
1220 return the name of the source file and the line nearest to the wanted
1221 location. */
1223 static bfd_boolean
1224 vms_find_nearest_line (bfd * abfd ATTRIBUTE_UNUSED,
1225 asection *section ATTRIBUTE_UNUSED,
1226 asymbol **symbols ATTRIBUTE_UNUSED,
1227 bfd_vma offset ATTRIBUTE_UNUSED,
1228 const char **file ATTRIBUTE_UNUSED,
1229 const char **func ATTRIBUTE_UNUSED,
1230 unsigned int *line ATTRIBUTE_UNUSED)
1232 #if VMS_DEBUG
1233 vms_debug (1, "vms_find_nearest_line (%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
1234 abfd, section->name, symbols, (long int)offset);
1235 #endif
1236 return _bfd_vms_find_nearest_dst_line (abfd, section, symbols, offset, file, func, line);
1239 static bfd_boolean
1240 vms_find_inliner_info (bfd * abfd ATTRIBUTE_UNUSED,
1241 const char **file ATTRIBUTE_UNUSED,
1242 const char **func ATTRIBUTE_UNUSED,
1243 unsigned int *line ATTRIBUTE_UNUSED)
1245 #if VMS_DEBUG
1246 vms_debug (1, "vms_find_inliner_info (%p, <ret>, <ret>, <ret>)\n",
1247 abfd);
1248 #endif
1249 return FALSE;
1252 /* Back-door to allow format-aware applications to create debug symbols
1253 while using BFD for everything else. Currently used by the assembler
1254 when creating COFF files. */
1256 static asymbol *
1257 vms_bfd_make_debug_symbol (bfd * abfd ATTRIBUTE_UNUSED,
1258 void *ptr ATTRIBUTE_UNUSED,
1259 unsigned long size ATTRIBUTE_UNUSED)
1261 #if VMS_DEBUG
1262 vms_debug (1, "vms_bfd_make_debug_symbol (%p, %p, %ld)\n", abfd, ptr, size);
1263 #endif
1264 return NULL;
1267 /* Read minisymbols. For minisymbols, we use the unmodified a.out
1268 symbols. The minisymbol_to_symbol function translates these into
1269 BFD asymbol structures. */
1271 static long
1272 vms_read_minisymbols (bfd * abfd,
1273 bfd_boolean dynamic,
1274 void * *minisymsp,
1275 unsigned int *sizep)
1277 #if VMS_DEBUG
1278 vms_debug (1, "vms_read_minisymbols (%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
1279 #endif
1280 return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
1283 /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1284 unmodified a.out symbol. The SYM argument is a structure returned
1285 by bfd_make_empty_symbol, which we fill in here. */
1287 static asymbol *
1288 vms_minisymbol_to_symbol (bfd * abfd,
1289 bfd_boolean dynamic,
1290 const void * minisym,
1291 asymbol *sym)
1293 #if VMS_DEBUG
1294 vms_debug (1, "vms_minisymbol_to_symbol (%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
1295 #endif
1296 return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
1299 /* Part 4.6, relocations. */
1301 /* Allocate the reloc buffer for the specified section. */
1303 static void
1304 alloc_reloc_stream (bfd *abfd ATTRIBUTE_UNUSED, asection *section,
1305 void *alloc_error)
1307 unsigned char *ptr;
1309 /* If there were no relocations, there is nothing to do. */
1310 if (section->reloc_count == 0)
1311 return;
1313 ptr = bfd_malloc (vms_section_data (section)->reloc_size);
1314 if (ptr == NULL)
1316 *(bfd_boolean *)alloc_error = TRUE;
1317 return;
1320 vms_section_data (section)->reloc_stream = ptr;
1323 /* Read in the relocs for the specified section and internalize them.
1325 The implementation is loosely based on the SOM code and made up
1326 of 3 distinct phases:
1328 1. When the VMS object is opened and parsed, the number and the size
1329 of the relocations are computed for all sections. This makes it
1330 possible to know upfront both which sections have no relocs and
1331 the size of the reloc buffers for the other sections, at virtually
1332 no cost for consumers that don't care about relocs at all.
1334 2. When vms_slurp_reloc_table is invoked for the first time on a section
1335 with relocs, the object is traversed and all the reloc information
1336 is saved in per-section reloc buffers. It would be very inefficient
1337 to scan the whole file on each invocation, so we slurp for all the
1338 sections at once.
1340 3. On subsequent invocations of vms_slurp_reloc_table, the relocs for the
1341 specified section are fetched from the buffer, decoded and internalized.
1342 The buffer is then freed since the internalized relocs are attached to
1343 the section, turning additional invocations of vms_slurp_reloc_table
1344 on the same section into no-ops.
1346 Since VMS objects have very few sections, it could be profitable to merge
1347 phase #2 and phase #3, i.e. to decode and internalize the relocs for all
1348 the sections at once. The current implementation is more elegant. */
1350 static bfd_boolean
1351 vms_slurp_reloc_table (bfd *abfd, asection *section, asymbol **symbols)
1353 arelent *internal_relocs;
1354 bfd_size_type amt;
1355 int err;
1357 /* If there were no relocations, there is nothing to do. */
1358 if (section->reloc_count == 0)
1359 return TRUE;
1361 /* Return saved information about the relocations if it is available. */
1362 if (section->relocation != NULL)
1363 return TRUE;
1365 /* If the relocation stream has not been slurped, do it now. */
1366 if (vms_section_data (section)->reloc_stream == NULL)
1368 bfd_boolean alloc_error = FALSE;
1369 int type;
1371 /* Size the reloc buffer for each section. */
1372 bfd_map_over_sections (abfd, alloc_reloc_stream, &alloc_error);
1373 if (alloc_error)
1374 return FALSE;
1376 if (bfd_seek (abfd, 0, SEEK_SET) != 0)
1377 return FALSE;
1379 /* Reset section pointer. */
1380 PRIV (image_section) = NULL;
1384 type = _bfd_vms_get_object_record (abfd);
1385 if (type != EOBJ_S_C_ETIR
1386 && type != EOBJ_S_C_EDBG
1387 && type != EOBJ_S_C_ETBT)
1388 continue;
1389 err = _bfd_vms_slurp_relocs (abfd);
1390 if (err != 0)
1392 #if VMS_DEBUG
1393 vms_debug (2, "slurp relocs failed with %d\n", err);
1394 #endif
1395 return FALSE;
1398 while (type != EOBJ_S_C_EEOM);
1401 amt = section->reloc_count * sizeof (arelent);
1402 internal_relocs = (arelent *) bfd_zalloc (abfd, amt);
1403 if (internal_relocs == NULL)
1404 return FALSE;
1406 /* Decode and internalize the relocations. */
1407 err = _bfd_vms_decode_relocs (abfd, internal_relocs, section, symbols);
1408 if (err != 0)
1410 #if VMS_DEBUG
1411 vms_debug (2, "decode relocs failed with %d\n", err);
1412 #endif
1413 return FALSE;
1416 /* We're done with the external relocations. Free them. */
1417 free (vms_section_data (section)->reloc_stream);
1418 vms_section_data (section)->reloc_stream = NULL;
1420 /* Save our results and return success. */
1421 section->relocation = internal_relocs;
1422 return TRUE;
1425 /* Return the number of bytes required to store the relocation
1426 information associated with the given section. */
1428 static long
1429 vms_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *section)
1431 return (section->reloc_count + 1) * sizeof (arelent *);
1434 /* Convert relocations from VMS (external) form into BFD internal
1435 form. Return the number of relocations. */
1437 static long
1438 vms_canonicalize_reloc (bfd *abfd, asection *section, arelent **relptr,
1439 asymbol **symbols)
1441 arelent *tblptr;
1442 int count;
1444 if (! vms_slurp_reloc_table (abfd, section, symbols))
1445 return -1;
1447 count = section->reloc_count;
1448 tblptr = section->relocation;
1450 while (count--)
1451 *relptr++ = tblptr++;
1453 *relptr = (arelent *) NULL;
1454 return section->reloc_count;
1457 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
1459 /* How to process the various reloc types. */
1461 static bfd_reloc_status_type
1462 reloc_nil (bfd * abfd ATTRIBUTE_UNUSED,
1463 arelent *reloc ATTRIBUTE_UNUSED,
1464 asymbol *sym ATTRIBUTE_UNUSED,
1465 void * data ATTRIBUTE_UNUSED,
1466 asection *sec ATTRIBUTE_UNUSED,
1467 bfd *output_bfd ATTRIBUTE_UNUSED,
1468 char **error_message ATTRIBUTE_UNUSED)
1470 #if VMS_DEBUG
1471 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd);
1472 vms_debug (2, "In section %s, symbol %s\n",
1473 sec->name, sym->name);
1474 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1475 reloc->sym_ptr_ptr[0]->name,
1476 (unsigned long)reloc->address,
1477 (unsigned long)reloc->addend, reloc->howto->name);
1478 vms_debug (2, "data at %p\n", data);
1479 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
1480 #endif
1482 return bfd_reloc_ok;
1485 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1486 from smaller values. Start with zero, widen, *then* decrement. */
1487 #define MINUS_ONE (((bfd_vma)0) - 1)
1489 static reloc_howto_type alpha_howto_table[] =
1491 HOWTO (ALPHA_R_IGNORE, /* Type. */
1492 0, /* Rightshift. */
1493 0, /* Size (0 = byte, 1 = short, 2 = long). */
1494 8, /* Bitsize. */
1495 TRUE, /* PC relative. */
1496 0, /* Bitpos. */
1497 complain_overflow_dont,/* Complain_on_overflow. */
1498 reloc_nil, /* Special_function. */
1499 "IGNORE", /* Name. */
1500 TRUE, /* Partial_inplace. */
1501 0, /* Source mask */
1502 0, /* Dest mask. */
1503 TRUE), /* PC rel offset. */
1505 /* A 64 bit reference to a symbol. */
1506 HOWTO (ALPHA_R_REFQUAD, /* Type. */
1507 0, /* Rightshift. */
1508 4, /* Size (0 = byte, 1 = short, 2 = long). */
1509 64, /* Bitsize. */
1510 FALSE, /* PC relative. */
1511 0, /* Bitpos. */
1512 complain_overflow_bitfield, /* Complain_on_overflow. */
1513 reloc_nil, /* Special_function. */
1514 "REFQUAD", /* Name. */
1515 TRUE, /* Partial_inplace. */
1516 MINUS_ONE, /* Source mask. */
1517 MINUS_ONE, /* Dest mask. */
1518 FALSE), /* PC rel offset. */
1520 /* A 21 bit branch. The native assembler generates these for
1521 branches within the text segment, and also fills in the PC
1522 relative offset in the instruction. */
1523 HOWTO (ALPHA_R_BRADDR, /* Type. */
1524 2, /* Rightshift. */
1525 2, /* Size (0 = byte, 1 = short, 2 = long). */
1526 21, /* Bitsize. */
1527 TRUE, /* PC relative. */
1528 0, /* Bitpos. */
1529 complain_overflow_signed, /* Complain_on_overflow. */
1530 reloc_nil, /* Special_function. */
1531 "BRADDR", /* Name. */
1532 TRUE, /* Partial_inplace. */
1533 0x1fffff, /* Source mask. */
1534 0x1fffff, /* Dest mask. */
1535 FALSE), /* PC rel offset. */
1537 /* A hint for a jump to a register. */
1538 HOWTO (ALPHA_R_HINT, /* Type. */
1539 2, /* Rightshift. */
1540 1, /* Size (0 = byte, 1 = short, 2 = long). */
1541 14, /* Bitsize. */
1542 TRUE, /* PC relative. */
1543 0, /* Bitpos. */
1544 complain_overflow_dont,/* Complain_on_overflow. */
1545 reloc_nil, /* Special_function. */
1546 "HINT", /* Name. */
1547 TRUE, /* Partial_inplace. */
1548 0x3fff, /* Source mask. */
1549 0x3fff, /* Dest mask. */
1550 FALSE), /* PC rel offset. */
1552 /* 16 bit PC relative offset. */
1553 HOWTO (ALPHA_R_SREL16, /* Type. */
1554 0, /* Rightshift. */
1555 1, /* Size (0 = byte, 1 = short, 2 = long). */
1556 16, /* Bitsize. */
1557 TRUE, /* PC relative. */
1558 0, /* Bitpos. */
1559 complain_overflow_signed, /* Complain_on_overflow. */
1560 reloc_nil, /* Special_function. */
1561 "SREL16", /* Name. */
1562 TRUE, /* Partial_inplace. */
1563 0xffff, /* Source mask. */
1564 0xffff, /* Dest mask. */
1565 FALSE), /* PC rel offset. */
1567 /* 32 bit PC relative offset. */
1568 HOWTO (ALPHA_R_SREL32, /* Type. */
1569 0, /* Rightshift. */
1570 2, /* Size (0 = byte, 1 = short, 2 = long). */
1571 32, /* Bitsize. */
1572 TRUE, /* PC relative. */
1573 0, /* Bitpos. */
1574 complain_overflow_signed, /* Complain_on_overflow. */
1575 reloc_nil, /* Special_function. */
1576 "SREL32", /* Name. */
1577 TRUE, /* Partial_inplace. */
1578 0xffffffff, /* Source mask. */
1579 0xffffffff, /* Dest mask. */
1580 FALSE), /* PC rel offset. */
1582 /* A 64 bit PC relative offset. */
1583 HOWTO (ALPHA_R_SREL64, /* Type. */
1584 0, /* Rightshift. */
1585 4, /* Size (0 = byte, 1 = short, 2 = long). */
1586 64, /* Bitsize. */
1587 TRUE, /* PC relative. */
1588 0, /* Bitpos. */
1589 complain_overflow_signed, /* Complain_on_overflow. */
1590 reloc_nil, /* Special_function. */
1591 "SREL64", /* Name. */
1592 TRUE, /* Partial_inplace. */
1593 MINUS_ONE, /* Source mask. */
1594 MINUS_ONE, /* Dest mask. */
1595 FALSE), /* PC rel offset. */
1597 /* Push a value on the reloc evaluation stack. */
1598 HOWTO (ALPHA_R_OP_PUSH, /* Type. */
1599 0, /* Rightshift. */
1600 0, /* Size (0 = byte, 1 = short, 2 = long). */
1601 0, /* Bitsize. */
1602 FALSE, /* PC relative. */
1603 0, /* Bitpos. */
1604 complain_overflow_dont,/* Complain_on_overflow. */
1605 reloc_nil, /* Special_function. */
1606 "OP_PUSH", /* Name. */
1607 FALSE, /* Partial_inplace. */
1608 0, /* Source mask. */
1609 0, /* Dest mask. */
1610 FALSE), /* PC rel offset. */
1612 /* Store the value from the stack at the given address. Store it in
1613 a bitfield of size r_size starting at bit position r_offset. */
1614 HOWTO (ALPHA_R_OP_STORE, /* Type. */
1615 0, /* Rightshift. */
1616 4, /* Size (0 = byte, 1 = short, 2 = long). */
1617 64, /* Bitsize. */
1618 FALSE, /* PC relative. */
1619 0, /* Bitpos. */
1620 complain_overflow_dont,/* Complain_on_overflow. */
1621 reloc_nil, /* Special_function. */
1622 "OP_STORE", /* Name. */
1623 FALSE, /* Partial_inplace. */
1624 0, /* Source mask. */
1625 MINUS_ONE, /* Dest mask. */
1626 FALSE), /* PC rel offset. */
1628 /* Subtract the reloc address from the value on the top of the
1629 relocation stack. */
1630 HOWTO (ALPHA_R_OP_PSUB, /* Type. */
1631 0, /* Rightshift. */
1632 0, /* Size (0 = byte, 1 = short, 2 = long). */
1633 0, /* Bitsize. */
1634 FALSE, /* PC relative. */
1635 0, /* Bitpos. */
1636 complain_overflow_dont,/* Complain_on_overflow. */
1637 reloc_nil, /* Special_function. */
1638 "OP_PSUB", /* Name. */
1639 FALSE, /* Partial_inplace. */
1640 0, /* Source mask. */
1641 0, /* Dest mask. */
1642 FALSE), /* PC rel offset. */
1644 /* Shift the value on the top of the relocation stack right by the
1645 given value. */
1646 HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
1647 0, /* Rightshift. */
1648 0, /* Size (0 = byte, 1 = short, 2 = long). */
1649 0, /* Bitsize. */
1650 FALSE, /* PC relative. */
1651 0, /* Bitpos. */
1652 complain_overflow_dont,/* Complain_on_overflow. */
1653 reloc_nil, /* Special_function. */
1654 "OP_PRSHIFT", /* Name. */
1655 FALSE, /* Partial_inplace. */
1656 0, /* Source mask. */
1657 0, /* Dest mask. */
1658 FALSE), /* PC rel offset. */
1660 /* Hack. Linkage is done by linker. */
1661 HOWTO (ALPHA_R_LINKAGE, /* Type. */
1662 0, /* Rightshift. */
1663 8, /* Size (0 = byte, 1 = short, 2 = long). */
1664 256, /* Bitsize. */
1665 FALSE, /* PC relative. */
1666 0, /* Bitpos. */
1667 complain_overflow_dont,/* Complain_on_overflow. */
1668 reloc_nil, /* Special_function. */
1669 "LINKAGE", /* Name. */
1670 FALSE, /* Partial_inplace. */
1671 0, /* Source mask. */
1672 0, /* Dest mask. */
1673 FALSE), /* PC rel offset. */
1675 /* A 32 bit reference to a symbol. */
1676 HOWTO (ALPHA_R_REFLONG, /* Type. */
1677 0, /* Rightshift. */
1678 2, /* Size (0 = byte, 1 = short, 2 = long). */
1679 32, /* Bitsize. */
1680 FALSE, /* PC relative. */
1681 0, /* Bitpos. */
1682 complain_overflow_bitfield, /* Complain_on_overflow. */
1683 reloc_nil, /* Special_function. */
1684 "REFLONG", /* Name. */
1685 TRUE, /* Partial_inplace. */
1686 0xffffffff, /* Source mask. */
1687 0xffffffff, /* Dest mask. */
1688 FALSE), /* PC rel offset. */
1690 /* A 64 bit reference to a procedure, written as 32 bit value. */
1691 HOWTO (ALPHA_R_CODEADDR, /* Type. */
1692 0, /* Rightshift. */
1693 4, /* Size (0 = byte, 1 = short, 2 = long). */
1694 64, /* Bitsize. */
1695 FALSE, /* PC relative. */
1696 0, /* Bitpos. */
1697 complain_overflow_signed,/* Complain_on_overflow. */
1698 reloc_nil, /* Special_function. */
1699 "CODEADDR", /* Name. */
1700 FALSE, /* Partial_inplace. */
1701 0xffffffff, /* Source mask. */
1702 0xffffffff, /* Dest mask. */
1703 FALSE), /* PC rel offset. */
1705 HOWTO (ALPHA_R_NOP, /* Type. */
1706 0, /* Rightshift. */
1707 3, /* Size (0 = byte, 1 = short, 2 = long). */
1708 0, /* Bitsize. */
1709 /* The following value must match that of ALPHA_R_BSR/ALPHA_R_BOH
1710 because the calculations for the 3 relocations are the same.
1711 See B.4.5.2 of the OpenVMS Linker Utility Manual. */
1712 TRUE, /* PC relative. */
1713 0, /* Bitpos. */
1714 complain_overflow_dont,/* Complain_on_overflow. */
1715 reloc_nil, /* Special_function. */
1716 "NOP", /* Name. */
1717 FALSE, /* Partial_inplace. */
1718 0xffffffff, /* Source mask. */
1719 0xffffffff, /* Dest mask. */
1720 FALSE), /* PC rel offset. */
1722 HOWTO (ALPHA_R_BSR, /* Type. */
1723 0, /* Rightshift. */
1724 3, /* Size (0 = byte, 1 = short, 2 = long). */
1725 0, /* Bitsize. */
1726 TRUE, /* PC relative. */
1727 0, /* Bitpos. */
1728 complain_overflow_dont,/* Complain_on_overflow. */
1729 reloc_nil, /* Special_function. */
1730 "BSR", /* Name. */
1731 FALSE, /* Partial_inplace. */
1732 0xffffffff, /* Source mask. */
1733 0xffffffff, /* Dest mask. */
1734 FALSE), /* PC rel offset. */
1736 HOWTO (ALPHA_R_LDA, /* Type. */
1737 0, /* Rightshift. */
1738 3, /* Size (0 = byte, 1 = short, 2 = long). */
1739 0, /* Bitsize. */
1740 FALSE, /* PC relative. */
1741 0, /* Bitpos. */
1742 complain_overflow_dont,/* Complain_on_overflow. */
1743 reloc_nil, /* Special_function. */
1744 "LDA", /* Name. */
1745 FALSE, /* Partial_inplace. */
1746 0xffffffff, /* Source mask. */
1747 0xffffffff, /* Dest mask. */
1748 FALSE), /* PC rel offset. */
1750 HOWTO (ALPHA_R_BOH, /* Type. */
1751 0, /* Rightshift. */
1752 3, /* Size (0 = byte, 1 = short, 2 = long, 3 = nil). */
1753 0, /* Bitsize. */
1754 TRUE, /* PC relative. */
1755 0, /* Bitpos. */
1756 complain_overflow_dont,/* Complain_on_overflow. */
1757 reloc_nil, /* Special_function. */
1758 "BOH", /* Name. */
1759 FALSE, /* Partial_inplace. */
1760 0xffffffff, /* Source mask. */
1761 0xffffffff, /* Dest mask. */
1762 FALSE), /* PC rel offset. */
1765 /* Return a pointer to a howto structure which, when invoked, will perform
1766 the relocation code on data from the architecture noted. */
1768 static const struct reloc_howto_struct *
1769 vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
1770 bfd_reloc_code_real_type code)
1772 int alpha_type;
1774 #if VMS_DEBUG
1775 vms_debug (1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code);
1776 #endif
1778 switch (code)
1780 case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
1781 case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
1782 case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
1783 case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
1784 case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
1785 case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
1786 case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
1787 case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
1788 case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
1789 case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
1790 case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
1791 case BFD_RELOC_ALPHA_NOP: alpha_type = ALPHA_R_NOP; break;
1792 case BFD_RELOC_ALPHA_BSR: alpha_type = ALPHA_R_BSR; break;
1793 case BFD_RELOC_ALPHA_LDA: alpha_type = ALPHA_R_LDA; break;
1794 case BFD_RELOC_ALPHA_BOH: alpha_type = ALPHA_R_BOH; break;
1795 default:
1796 (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
1797 return NULL;
1799 #if VMS_DEBUG
1800 vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
1801 #endif
1802 return & alpha_howto_table[alpha_type];
1805 static reloc_howto_type *
1806 vms_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1807 const char *r_name)
1809 unsigned int i;
1811 for (i = 0;
1812 i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
1813 i++)
1814 if (alpha_howto_table[i].name != NULL
1815 && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
1816 return &alpha_howto_table[i];
1818 return NULL;
1821 /* Part 4.7, writing an object file. */
1823 /* Set the architecture and machine type in BFD abfd to arch and mach.
1824 Find the correct pointer to a structure and insert it into the arch_info
1825 pointer. */
1827 static bfd_boolean
1828 vms_set_arch_mach (bfd * abfd,
1829 enum bfd_architecture arch ATTRIBUTE_UNUSED,
1830 unsigned long mach ATTRIBUTE_UNUSED)
1832 #if VMS_DEBUG
1833 vms_debug (1, "vms_set_arch_mach (%p, %d, %ld)\n", abfd, arch, mach);
1834 #endif
1836 if (arch != bfd_arch_alpha
1837 && arch != bfd_arch_vax
1838 && arch != bfd_arch_unknown)
1839 return FALSE;
1841 return bfd_default_set_arch_mach (abfd, arch, mach);
1844 /* Sets the contents of the section section in BFD abfd to the data starting
1845 in memory at LOCATION. The data is written to the output section starting
1846 at offset offset for count bytes.
1848 Normally TRUE is returned, else FALSE. Possible error returns are:
1849 o bfd_error_no_contents - The output section does not have the
1850 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1851 o and some more too */
1853 static bfd_boolean
1854 vms_set_section_contents (bfd * abfd,
1855 asection *section,
1856 const void * location,
1857 file_ptr offset,
1858 bfd_size_type count)
1860 #if VMS_DEBUG
1861 vms_debug (1, "vms_set_section_contents (%p, sec %s, loc %p, off %ld, count %d)\n",
1862 abfd, section->name, location, (long int)offset, (int)count);
1863 vms_debug (2, "size %d\n", (int) section->size);
1864 #endif
1865 if (count == (bfd_size_type)0)
1866 return TRUE;
1868 if (section->contents == NULL)
1869 section->contents = bfd_alloc (abfd, section->size);
1870 if (section->contents == NULL)
1871 return FALSE;
1873 memcpy (section->contents + offset, location, (size_t) count);
1874 return TRUE;
1877 /* Part 4.8, linker. */
1879 /* Get the size of the section headers. */
1881 static int
1882 vms_sizeof_headers (bfd * abfd ATTRIBUTE_UNUSED,
1883 struct bfd_link_info *info ATTRIBUTE_UNUSED)
1885 #if VMS_DEBUG
1886 vms_debug (1, "vms_sizeof_headers (%p, %s)\n", abfd, (reloc)?"True":"False");
1887 #endif
1888 return 0;
1891 /* Provides default handling of relocation effort for back ends
1892 which can't be bothered to do it efficiently. */
1894 static bfd_byte *
1895 vms_bfd_get_relocated_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
1896 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1897 struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
1898 bfd_byte *data ATTRIBUTE_UNUSED,
1899 bfd_boolean relocatable ATTRIBUTE_UNUSED,
1900 asymbol **symbols ATTRIBUTE_UNUSED)
1902 #if VMS_DEBUG
1903 vms_debug (1, "vms_bfd_get_relocated_section_contents (%p, %p, %p, %p, %s, %p)\n",
1904 abfd, link_info, link_order, data, (relocatable)?"True":"False", symbols);
1905 #endif
1906 return NULL;
1909 /* ??? */
1911 static bfd_boolean
1912 vms_bfd_relax_section (bfd * abfd ATTRIBUTE_UNUSED,
1913 asection *section ATTRIBUTE_UNUSED,
1914 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1915 bfd_boolean *again ATTRIBUTE_UNUSED)
1917 #if VMS_DEBUG
1918 vms_debug (1, "vms_bfd_relax_section (%p, %s, %p, <ret>)\n",
1919 abfd, section->name, link_info);
1920 #endif
1921 return TRUE;
1924 static bfd_boolean
1925 vms_bfd_gc_sections (bfd * abfd ATTRIBUTE_UNUSED,
1926 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1928 #if VMS_DEBUG
1929 vms_debug (1, "vms_bfd_gc_sections (%p, %p)\n", abfd, link_info);
1930 #endif
1931 return TRUE;
1934 static bfd_boolean
1935 vms_bfd_merge_sections (bfd * abfd ATTRIBUTE_UNUSED,
1936 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1938 #if VMS_DEBUG
1939 vms_debug (1, "vms_bfd_merge_sections (%p, %p)\n", abfd, link_info);
1940 #endif
1941 return TRUE;
1944 /* Create a hash table for the linker. Different backends store
1945 different information in this table. */
1947 static struct bfd_link_hash_table *
1948 vms_bfd_link_hash_table_create (bfd * abfd ATTRIBUTE_UNUSED)
1950 #if VMS_DEBUG
1951 vms_debug (1, "vms_bfd_link_hash_table_create (%p)\n", abfd);
1952 #endif
1953 return NULL;
1956 /* Free a linker hash table. */
1958 static void
1959 vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED)
1961 #if VMS_DEBUG
1962 vms_debug (1, "vms_bfd_link_hash_table_free (%p)\n", abfd);
1963 #endif
1966 /* Add symbols from this object file into the hash table. */
1968 static bfd_boolean
1969 vms_bfd_link_add_symbols (bfd * abfd ATTRIBUTE_UNUSED,
1970 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1972 #if VMS_DEBUG
1973 vms_debug (1, "vms_bfd_link_add_symbols (%p, %p)\n", abfd, link_info);
1974 #endif
1975 return FALSE;
1978 /* Do a link based on the link_order structures attached to each
1979 section of the BFD. */
1981 static bfd_boolean
1982 vms_bfd_final_link (bfd * abfd ATTRIBUTE_UNUSED,
1983 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1985 #if VMS_DEBUG
1986 vms_debug (1, "vms_bfd_final_link (%p, %p)\n", abfd, link_info);
1987 #endif
1988 return TRUE;
1991 /* Should this section be split up into smaller pieces during linking. */
1993 static bfd_boolean
1994 vms_bfd_link_split_section (bfd * abfd ATTRIBUTE_UNUSED,
1995 asection *section ATTRIBUTE_UNUSED)
1997 #if VMS_DEBUG
1998 vms_debug (1, "vms_bfd_link_split_section (%p, %s)\n", abfd, section->name);
1999 #endif
2000 return FALSE;
2003 /* Part 4.9, dynamic symbols and relocations. */
2005 /* Get the amount of memory required to hold the dynamic symbols. */
2007 static long
2008 vms_get_dynamic_symtab_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
2010 #if VMS_DEBUG
2011 vms_debug (1, "vms_get_dynamic_symtab_upper_bound (%p)\n", abfd);
2012 #endif
2013 return 0L;
2016 static bfd_boolean
2017 vms_bfd_print_private_bfd_data (bfd * abfd ATTRIBUTE_UNUSED,
2018 void *file ATTRIBUTE_UNUSED)
2020 #if VMS_DEBUG
2021 vms_debug (1, "vms_bfd_print_private_bfd_data (%p)\n", abfd);
2022 #endif
2023 return FALSE;
2026 /* Read in the dynamic symbols. */
2028 static long
2029 vms_canonicalize_dynamic_symtab (bfd * abfd ATTRIBUTE_UNUSED,
2030 asymbol **symbols ATTRIBUTE_UNUSED)
2032 #if VMS_DEBUG
2033 vms_debug (1, "vms_canonicalize_dynamic_symtab (%p, <ret>)\n", abfd);
2034 #endif
2035 return 0L;
2038 /* Get the amount of memory required to hold the dynamic relocs. */
2040 static long
2041 vms_get_dynamic_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
2043 #if VMS_DEBUG
2044 vms_debug (1, "vms_get_dynamic_reloc_upper_bound (%p)\n", abfd);
2045 #endif
2046 return 0L;
2049 /* Read in the dynamic relocs. */
2051 static long
2052 vms_canonicalize_dynamic_reloc (bfd * abfd ATTRIBUTE_UNUSED,
2053 arelent **arel ATTRIBUTE_UNUSED,
2054 asymbol **symbols ATTRIBUTE_UNUSED)
2056 #if VMS_DEBUG
2057 vms_debug (1, "vms_canonicalize_dynamic_reloc (%p)\n", abfd);
2058 #endif
2059 return 0L;
2062 const bfd_target vms_alpha_vec =
2064 "vms-alpha", /* Name. */
2065 bfd_target_evax_flavour,
2066 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
2067 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
2069 (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
2070 | WP_TEXT | D_PAGED), /* Object flags. */
2071 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
2072 | SEC_READONLY | SEC_CODE | SEC_DATA
2073 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
2074 0, /* symbol_leading_char. */
2075 ' ', /* ar_pad_char. */
2076 15, /* ar_max_namelen. */
2077 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2078 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2079 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
2080 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2081 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2082 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
2084 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
2085 vms_archive_p, _bfd_dummy_target},
2086 {bfd_false, vms_mkobject, /* bfd_set_format. */
2087 _bfd_generic_mkarchive, bfd_false},
2088 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
2089 _bfd_write_archive_contents, bfd_false},
2091 BFD_JUMP_TABLE_GENERIC (vms),
2092 BFD_JUMP_TABLE_COPY (vms),
2093 BFD_JUMP_TABLE_CORE (vms),
2094 BFD_JUMP_TABLE_ARCHIVE (vms),
2095 BFD_JUMP_TABLE_SYMBOLS (vms),
2096 BFD_JUMP_TABLE_RELOCS (vms),
2097 BFD_JUMP_TABLE_WRITE (vms),
2098 BFD_JUMP_TABLE_LINK (vms),
2099 BFD_JUMP_TABLE_DYNAMIC (vms),
2101 NULL,
2103 (PTR) 0
2106 const bfd_target vms_vax_vec =
2108 "vms-vax", /* Name. */
2109 bfd_target_ovax_flavour,
2110 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
2111 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
2113 (HAS_RELOC | HAS_SYMS /* Object flags. */
2114 | WP_TEXT | D_PAGED
2115 | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
2117 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
2118 | SEC_READONLY | SEC_CODE | SEC_DATA
2119 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
2120 0, /* symbol_leading_char */
2121 ' ', /* ar_pad_char */
2122 15, /* ar_max_namelen */
2123 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2124 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2125 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
2126 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
2127 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
2128 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs. */
2130 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
2131 vms_archive_p, _bfd_dummy_target},
2132 {bfd_false, vms_mkobject, /* bfd_set_format. */
2133 _bfd_generic_mkarchive, bfd_false},
2134 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
2135 _bfd_write_archive_contents, bfd_false},
2137 BFD_JUMP_TABLE_GENERIC (vms),
2138 BFD_JUMP_TABLE_COPY (vms),
2139 BFD_JUMP_TABLE_CORE (vms),
2140 BFD_JUMP_TABLE_ARCHIVE (vms),
2141 BFD_JUMP_TABLE_SYMBOLS (vms),
2142 BFD_JUMP_TABLE_RELOCS (vms),
2143 BFD_JUMP_TABLE_WRITE (vms),
2144 BFD_JUMP_TABLE_LINK (vms),
2145 BFD_JUMP_TABLE_DYNAMIC (vms),
2147 NULL,
2149 (PTR) 0