daily update
[binutils.git] / bfd / vms.c
blobd2d98310ca3c18a727c111e8af455f3e040cc2e7
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 Free Software Foundation, Inc.
6 Written by Klaus K"ampf (kkaempf@rmi.de)
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "bfdlink.h"
25 #include "libbfd.h"
27 #include "vms.h"
29 #define vms_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
30 #define vms_make_empty_symbol _bfd_generic_make_empty_symbol
31 #define vms_bfd_link_just_syms _bfd_generic_link_just_syms
32 #define vms_bfd_is_group_section bfd_generic_is_group_section
33 #define vms_bfd_discard_group bfd_generic_discard_group
34 #define vms_section_already_linked _bfd_generic_section_already_linked
35 #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
36 #define vms_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
38 static unsigned int priv_section_count;
39 extern const bfd_target vms_vax_vec;
40 extern const bfd_target vms_alpha_vec;
42 /* Initialize private data. */
44 static bfd_boolean
45 vms_initialize (bfd * abfd)
47 int i;
48 bfd_size_type amt;
50 bfd_set_start_address (abfd, (bfd_vma) -1);
52 amt = sizeof (struct vms_private_data_struct);
53 abfd->tdata.any = bfd_alloc (abfd, amt);
54 if (abfd->tdata.any == NULL)
55 return FALSE;
57 #ifdef __ALPHA
58 PRIV (is_vax) = FALSE;
59 #else
60 PRIV (is_vax) = TRUE;
61 #endif
62 PRIV (vms_buf) = NULL;
63 PRIV (buf_size) = 0;
64 PRIV (rec_length) = 0;
65 PRIV (file_format) = FF_UNKNOWN;
66 PRIV (fixup_done) = FALSE;
67 PRIV (sections) = NULL;
69 amt = sizeof (struct stack_struct) * STACKSIZE;
70 PRIV (stack) = bfd_alloc (abfd, amt);
71 if (PRIV (stack) == NULL)
72 goto error_ret1;
73 PRIV (stackptr) = 0;
75 amt = sizeof (struct bfd_hash_table);
76 PRIV (vms_symbol_table) = bfd_alloc (abfd, amt);
77 if (PRIV (vms_symbol_table) == NULL)
78 goto error_ret1;
80 if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc,
81 sizeof (vms_symbol_entry)))
82 goto error_ret1;
84 amt = sizeof (struct location_struct) * LOCATION_SAVE_SIZE;
85 PRIV (location_stack) = bfd_alloc (abfd, amt);
86 if (PRIV (location_stack) == NULL)
87 goto error_ret2;
89 for (i = 0; i < VMS_SECTION_COUNT; i++)
90 PRIV (vms_section_table)[i] = NULL;
92 amt = MAX_OUTREC_SIZE;
93 PRIV (output_buf) = bfd_alloc (abfd, amt);
94 if (PRIV (output_buf) == NULL)
95 goto error_ret2;
97 PRIV (push_level) = 0;
98 PRIV (pushed_size) = 0;
99 PRIV (length_pos) = 2;
100 PRIV (output_size) = 0;
101 PRIV (output_alignment) = 1;
103 return TRUE;
105 error_ret2:
106 bfd_hash_table_free (PRIV (vms_symbol_table));
107 error_ret1:
108 bfd_release (abfd, abfd->tdata.any);
109 abfd->tdata.any = NULL;
110 return FALSE;
113 /* Fill symbol->section with section ptr
114 symbol->section is filled with the section index for defined symbols
115 during reading the GSD/EGSD section. But we need the pointer to the
116 bfd section later.
118 It has the correct value for referenced (undefined section) symbols
120 called from bfd_hash_traverse in vms_fixup_sections. */
122 static bfd_boolean
123 fill_section_ptr (struct bfd_hash_entry * entry, void * sections)
125 asection *sec;
126 asymbol *sym;
128 sym = ((vms_symbol_entry *) entry)->symbol;
129 sec = sym->section;
131 #if VMS_DEBUG
132 vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
133 #endif
135 /* Fill forward references (these contain section number, not section ptr). */
136 if ((unsigned int) (size_t) sec < priv_section_count)
137 sec = ((vms_symbol_entry *) entry)->symbol->section =
138 ((asection **) sections)[(unsigned int) (size_t) sec];
140 if (strcmp (sym->name, sec->name) == 0)
141 sym->flags |= BSF_SECTION_SYM;
143 return TRUE;
146 /* Fixup sections
147 set up all pointers and arrays, counters and sizes are fixed now
149 we build a private sections vector for easy access since sections
150 are always referenced by an index number.
152 alloc PRIV(sections) according to abfd->section_count
153 copy abfd->sections to PRIV(sections). */
155 static bfd_boolean
156 vms_fixup_sections (bfd * abfd)
158 if (PRIV (fixup_done))
159 return TRUE;
161 /* Traverse symbol table and fill in all section pointers. */
163 /* Can't provide section count as argument to fill_section_ptr(). */
164 priv_section_count = PRIV (section_count);
165 bfd_hash_traverse (PRIV (vms_symbol_table), fill_section_ptr, (PRIV (sections)));
167 PRIV (fixup_done) = TRUE;
169 return TRUE;
172 /* Check the format for a file being read.
173 Return a (bfd_target *) if it's an object file or zero if not. */
175 static const struct bfd_target *
176 vms_object_p (bfd * abfd)
178 int err = 0;
179 int prev_type;
180 const struct bfd_target *target_vector = NULL;
181 const bfd_arch_info_type *arch = NULL;
182 void * tdata_save = abfd->tdata.any;
183 bfd_vma saddr_save = bfd_get_start_address (abfd);
185 #if VMS_DEBUG
186 vms_debug (1, "vms_object_p (%p)\n", abfd);
187 #endif
189 if (!vms_initialize (abfd))
190 goto error_ret;
192 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
193 goto err_wrong_format;
195 prev_type = -1;
199 #if VMS_DEBUG
200 vms_debug (7, "reading at %08lx\n", bfd_tell (abfd));
201 #endif
202 if (_bfd_vms_next_record (abfd) < 0)
204 #if VMS_DEBUG
205 vms_debug (2, "next_record failed\n");
206 #endif
207 goto err_wrong_format;
210 if ((prev_type == EOBJ_S_C_EGSD)
211 && (PRIV (rec_type) != EOBJ_S_C_EGSD))
213 if (! vms_fixup_sections (abfd))
215 #if VMS_DEBUG
216 vms_debug (2, "vms_fixup_sections failed\n");
217 #endif
218 goto err_wrong_format;
222 prev_type = PRIV (rec_type);
224 if (target_vector == NULL)
226 if (prev_type <= OBJ_S_C_MAXRECTYP)
227 target_vector = & vms_vax_vec;
228 else
229 target_vector = & vms_alpha_vec;
232 switch (prev_type)
234 case OBJ_S_C_HDR:
235 case EOBJ_S_C_EMH:
236 err = _bfd_vms_slurp_hdr (abfd, prev_type);
237 break;
238 case OBJ_S_C_EOM:
239 case OBJ_S_C_EOMW:
240 case EOBJ_S_C_EEOM:
241 err = _bfd_vms_slurp_eom (abfd, prev_type);
242 break;
243 case OBJ_S_C_GSD:
244 case EOBJ_S_C_EGSD:
245 err = _bfd_vms_slurp_gsd (abfd, prev_type);
246 break;
247 case OBJ_S_C_TIR:
248 case EOBJ_S_C_ETIR:
249 err = _bfd_vms_slurp_tir (abfd, prev_type);
250 break;
251 case OBJ_S_C_DBG:
252 case EOBJ_S_C_EDBG:
253 err = _bfd_vms_slurp_dbg (abfd, prev_type);
254 break;
255 case OBJ_S_C_TBT:
256 case EOBJ_S_C_ETBT:
257 err = _bfd_vms_slurp_tbt (abfd, prev_type);
258 break;
259 case OBJ_S_C_LNK:
260 err = _bfd_vms_slurp_lnk (abfd, prev_type);
261 break;
262 default:
263 err = -1;
265 if (err != 0)
267 #if VMS_DEBUG
268 vms_debug (2, "slurp type %d failed with %d\n", prev_type, err);
269 #endif
270 goto err_wrong_format;
273 while ((prev_type != EOBJ_S_C_EEOM) && (prev_type != OBJ_S_C_EOM) && (prev_type != OBJ_S_C_EOMW));
275 if (target_vector == & vms_vax_vec)
277 if (! vms_fixup_sections (abfd))
279 #if VMS_DEBUG
280 vms_debug (2, "vms_fixup_sections failed\n");
281 #endif
282 goto err_wrong_format;
285 /* Set arch_info to vax. */
287 arch = bfd_scan_arch ("vax");
288 PRIV (is_vax) = TRUE;
289 #if VMS_DEBUG
290 vms_debug (2, "arch is vax\n");
291 #endif
293 else if (target_vector == & vms_alpha_vec)
295 /* Set arch_info to alpha. */
297 arch = bfd_scan_arch ("alpha");
298 PRIV (is_vax) = FALSE;
299 #if VMS_DEBUG
300 vms_debug (2, "arch is alpha\n");
301 #endif
304 if (arch == NULL)
306 #if VMS_DEBUG
307 vms_debug (2, "arch not found\n");
308 #endif
309 goto err_wrong_format;
311 abfd->arch_info = arch;
313 return target_vector;
315 err_wrong_format:
316 bfd_set_error (bfd_error_wrong_format);
317 error_ret:
318 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
319 bfd_release (abfd, abfd->tdata.any);
320 abfd->tdata.any = tdata_save;
321 bfd_set_start_address (abfd, saddr_save);
322 return NULL;
325 /* Check the format for a file being read.
326 Return a (bfd_target *) if it's an archive file or zero. */
328 static const struct bfd_target *
329 vms_archive_p (bfd * abfd ATTRIBUTE_UNUSED)
331 #if VMS_DEBUG
332 vms_debug (1, "vms_archive_p (%p)\n", abfd);
333 #endif
335 return NULL;
338 /* Set the format of a file being written. */
340 static bfd_boolean
341 vms_mkobject (bfd * abfd)
343 #if VMS_DEBUG
344 vms_debug (1, "vms_mkobject (%p)\n", abfd);
345 #endif
347 if (!vms_initialize (abfd))
348 return FALSE;
351 #ifdef __VAX
352 const bfd_arch_info_type *arch = bfd_scan_arch ("vax");
353 #else
354 const bfd_arch_info_type *arch = bfd_scan_arch ("alpha");
355 #endif
356 if (arch == NULL)
358 bfd_set_error (bfd_error_wrong_format);
359 return FALSE;
361 abfd->arch_info = arch;
364 return TRUE;
367 /* Write cached information into a file being written, at bfd_close. */
369 static bfd_boolean
370 vms_write_object_contents (bfd * abfd)
372 #if VMS_DEBUG
373 vms_debug (1, "vms_write_object_contents (%p)\n", abfd);
374 #endif
376 if (abfd->section_count > 0) /* we have sections */
378 if (PRIV (is_vax))
380 if (_bfd_vms_write_hdr (abfd, OBJ_S_C_HDR) != 0)
381 return FALSE;
382 if (_bfd_vms_write_gsd (abfd, OBJ_S_C_GSD) != 0)
383 return FALSE;
384 if (_bfd_vms_write_tir (abfd, OBJ_S_C_TIR) != 0)
385 return FALSE;
386 if (_bfd_vms_write_tbt (abfd, OBJ_S_C_TBT) != 0)
387 return FALSE;
388 if (_bfd_vms_write_dbg (abfd, OBJ_S_C_DBG) != 0)
389 return FALSE;
390 if (abfd->section_count > 255)
392 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
393 return FALSE;
395 else
397 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
398 return FALSE;
401 else
403 if (_bfd_vms_write_hdr (abfd, EOBJ_S_C_EMH) != 0)
404 return FALSE;
405 if (_bfd_vms_write_gsd (abfd, EOBJ_S_C_EGSD) != 0)
406 return FALSE;
407 if (_bfd_vms_write_tir (abfd, EOBJ_S_C_ETIR) != 0)
408 return FALSE;
409 if (_bfd_vms_write_tbt (abfd, EOBJ_S_C_ETBT) != 0)
410 return FALSE;
411 if (_bfd_vms_write_dbg (abfd, EOBJ_S_C_EDBG) != 0)
412 return FALSE;
413 if (_bfd_vms_write_eom (abfd, EOBJ_S_C_EEOM) != 0)
414 return FALSE;
417 return TRUE;
420 /* 4.1, generic. */
422 /* Called when the BFD is being closed to do any necessary cleanup. */
424 static bfd_boolean
425 vms_close_and_cleanup (bfd * abfd)
427 #if VMS_DEBUG
428 vms_debug (1, "vms_close_and_cleanup (%p)\n", abfd);
429 #endif
430 if (abfd == NULL)
431 return TRUE;
433 if (PRIV (vms_buf) != NULL)
434 free (PRIV (vms_buf));
436 if (PRIV (sections) != NULL)
437 free (PRIV (sections));
439 if (PRIV (vms_symbol_table))
440 bfd_hash_table_free (PRIV (vms_symbol_table));
442 bfd_release (abfd, abfd->tdata.any);
443 abfd->tdata.any = NULL;
445 return TRUE;
448 /* Ask the BFD to free all cached information. */
450 static bfd_boolean
451 vms_bfd_free_cached_info (bfd * abfd ATTRIBUTE_UNUSED)
453 #if VMS_DEBUG
454 vms_debug (1, "vms_bfd_free_cached_info (%p)\n", abfd);
455 #endif
456 return TRUE;
459 /* Called when a new section is created. */
461 static bfd_boolean
462 vms_new_section_hook (bfd * abfd, asection *section)
464 /* Count hasn't been incremented yet. */
465 unsigned int section_count = abfd->section_count + 1;
467 #if VMS_DEBUG
468 vms_debug (1, "vms_new_section_hook (%p, [%d]%s), count %d\n",
469 abfd, section->index, section->name, section_count);
470 #endif
471 bfd_set_section_alignment (abfd, section, 4);
473 if (section_count > PRIV (section_count))
475 bfd_size_type amt = section_count;
476 amt *= sizeof (asection *);
477 PRIV (sections) = bfd_realloc (PRIV (sections), amt);
478 if (PRIV (sections) == NULL)
479 return FALSE;
480 PRIV (section_count) = section_count;
482 #if VMS_DEBUG
483 vms_debug (6, "section_count: %d\n", PRIV (section_count));
484 #endif
485 PRIV (sections)[section->index] = section;
486 #if VMS_DEBUG
487 vms_debug (7, "%d: %s\n", section->index, section->name);
488 #endif
490 return _bfd_generic_new_section_hook (abfd, section);
493 /* Read the contents of a section.
494 buf points to a buffer of buf_size bytes to be filled with
495 section data (starting at offset into section) */
497 static bfd_boolean
498 vms_get_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
499 asection *section ATTRIBUTE_UNUSED,
500 void * buf ATTRIBUTE_UNUSED,
501 file_ptr offset ATTRIBUTE_UNUSED,
502 bfd_size_type buf_size ATTRIBUTE_UNUSED)
504 #if VMS_DEBUG
505 vms_debug (1, "vms_get_section_contents (%p, %s, %p, off %ld, size %d)\n",
506 abfd, section->name, buf, offset, (int)buf_size);
507 #endif
509 /* Shouldn't be called, since all sections are IN_MEMORY. */
510 return FALSE;
513 /* Read the contents of a section.
514 buf points to a buffer of buf_size bytes to be filled with
515 section data (starting at offset into section). */
517 static bfd_boolean
518 vms_get_section_contents_in_window (bfd * abfd ATTRIBUTE_UNUSED,
519 asection *section ATTRIBUTE_UNUSED,
520 bfd_window *w ATTRIBUTE_UNUSED,
521 file_ptr offset ATTRIBUTE_UNUSED,
522 bfd_size_type count ATTRIBUTE_UNUSED)
524 #if VMS_DEBUG
525 vms_debug (1, "vms_get_section_contents_in_window (%p, %s, %p, off %ld, count %d)\n",
526 abfd, section->name, w, offset, (int)count);
527 #endif
529 /* Shouldn't be called, since all sections are IN_MEMORY. */
530 return FALSE;
533 /* Part 4.2, copy private data. */
535 /* Called to copy BFD general private data from one object file
536 to another. */
538 static bfd_boolean
539 vms_bfd_copy_private_bfd_data (bfd *src ATTRIBUTE_UNUSED,
540 bfd *dest ATTRIBUTE_UNUSED)
542 #if VMS_DEBUG
543 vms_debug (1, "vms_bfd_copy_private_bfd_data (%p, %p)\n", src, dest);
544 #endif
545 return TRUE;
548 /* Merge private BFD information from the BFD @var{ibfd} to the
549 the output file BFD @var{obfd} when linking. Return <<TRUE>>
550 on success, <<FALSE>> on error. Possible error returns are:
552 o <<bfd_error_no_memory>> -
553 Not enough memory exists to create private data for @var{obfd}. */
555 static bfd_boolean
556 vms_bfd_merge_private_bfd_data (bfd * ibfd ATTRIBUTE_UNUSED,
557 bfd * obfd ATTRIBUTE_UNUSED)
559 #if VMS_DEBUG
560 vms_debug (1,"vms_bfd_merge_private_bfd_data (%p, %p)\n", ibfd, obfd);
561 #endif
562 return TRUE;
565 /* Set private BFD flag information in the BFD @var{abfd}.
566 Return <<TRUE>> on success, <<FALSE>> on error. Possible error
567 returns are:
569 o <<bfd_error_no_memory>> -
570 Not enough memory exists to create private data for @var{obfd}. */
572 static bfd_boolean
573 vms_bfd_set_private_flags (bfd * abfd ATTRIBUTE_UNUSED,
574 flagword flags ATTRIBUTE_UNUSED)
576 #if VMS_DEBUG
577 vms_debug (1,"vms_bfd_set_private_flags (%p, %lx)\n", abfd, (long)flags);
578 #endif
579 return TRUE;
582 /* Called to copy BFD private section data from one object file
583 to another. */
585 static bfd_boolean
586 vms_bfd_copy_private_section_data (bfd *srcbfd ATTRIBUTE_UNUSED,
587 asection *srcsec ATTRIBUTE_UNUSED,
588 bfd *dstbfd ATTRIBUTE_UNUSED,
589 asection *dstsec ATTRIBUTE_UNUSED)
591 #if VMS_DEBUG
592 vms_debug (1, "vms_bfd_copy_private_section_data (%p, %s, %p, %s)\n",
593 srcbfd, srcsec->name, dstbfd, dstsec->name);
594 #endif
595 return TRUE;
598 /* Called to copy BFD private symbol data from one object file
599 to another. */
601 static bfd_boolean
602 vms_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED,
603 asymbol *isym ATTRIBUTE_UNUSED,
604 bfd *obfd ATTRIBUTE_UNUSED,
605 asymbol *osym ATTRIBUTE_UNUSED)
607 #if VMS_DEBUG
608 vms_debug (1, "vms_bfd_copy_private_symbol_data (%p, %s, %p, %s)\n",
609 ibfd, isym->name, obfd, osym->name);
610 #endif
611 return TRUE;
614 /* Part 4.3, core file. */
616 /* Return a read-only string explaining which program was running
617 when it failed and produced the core file abfd. */
619 static char *
620 vms_core_file_failing_command (bfd * abfd ATTRIBUTE_UNUSED)
622 #if VMS_DEBUG
623 vms_debug (1, "vms_core_file_failing_command (%p)\n", abfd);
624 #endif
625 return NULL;
628 /* Returns the signal number which caused the core dump which
629 generated the file the BFD abfd is attached to. */
631 static int
632 vms_core_file_failing_signal (bfd * abfd ATTRIBUTE_UNUSED)
634 #if VMS_DEBUG
635 vms_debug (1, "vms_core_file_failing_signal (%p)\n", abfd);
636 #endif
637 return 0;
640 /* Return TRUE if the core file attached to core_bfd was generated
641 by a run of the executable file attached to exec_bfd, FALSE otherwise. */
643 static bfd_boolean
644 vms_core_file_matches_executable_p (bfd * abfd ATTRIBUTE_UNUSED,
645 bfd *bbfd ATTRIBUTE_UNUSED)
647 #if VMS_DEBUG
648 vms_debug (1, "vms_core_file_matches_executable_p (%p, %p)\n", abfd, bbfd);
649 #endif
650 return FALSE;
653 /* Part 4.4, archive. */
655 /* ??? do something with an archive map.
656 Return FALSE on error, TRUE otherwise. */
658 static bfd_boolean
659 vms_slurp_armap (bfd * abfd ATTRIBUTE_UNUSED)
661 #if VMS_DEBUG
662 vms_debug (1, "vms_slurp_armap (%p)\n", abfd);
663 #endif
664 return FALSE;
667 /* ??? do something with an extended name table.
668 Return FALSE on error, TRUE otherwise. */
670 static bfd_boolean
671 vms_slurp_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED)
673 #if VMS_DEBUG
674 vms_debug (1, "vms_slurp_extended_name_table (%p)\n", abfd);
675 #endif
676 return FALSE;
679 /* ??? do something with an extended name table.
680 Return FALSE on error, TRUE otherwise. */
682 static bfd_boolean
683 vms_construct_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED,
684 char **tabloc ATTRIBUTE_UNUSED,
685 bfd_size_type *tablen ATTRIBUTE_UNUSED,
686 const char **name ATTRIBUTE_UNUSED)
688 #if VMS_DEBUG
689 vms_debug (1, "vms_construct_extended_name_table (%p)\n", abfd);
690 #endif
691 return FALSE;
694 /* Truncate the name of an archive to match system-dependent restrictions. */
696 static void
697 vms_truncate_arname (bfd * abfd ATTRIBUTE_UNUSED,
698 const char *pathname ATTRIBUTE_UNUSED,
699 char *arhdr ATTRIBUTE_UNUSED)
701 #if VMS_DEBUG
702 vms_debug (1, "vms_truncate_arname (%p, %s, %s)\n", abfd, pathname, arhdr);
703 #endif
704 return;
707 /* ??? write archive map. */
709 static bfd_boolean
710 vms_write_armap (bfd *arch ATTRIBUTE_UNUSED,
711 unsigned int elength ATTRIBUTE_UNUSED,
712 struct orl *map ATTRIBUTE_UNUSED,
713 unsigned int orl_count ATTRIBUTE_UNUSED,
714 int stridx ATTRIBUTE_UNUSED)
716 #if VMS_DEBUG
717 vms_debug (1, "vms_write_armap (%p, %d, %p, %d %d)\n",
718 arch, elength, map, orl_count, stridx);
719 #endif
720 return TRUE;
723 /* Read archive header ??? */
725 static void *
726 vms_read_ar_hdr (bfd * abfd ATTRIBUTE_UNUSED)
728 #if VMS_DEBUG
729 vms_debug (1, "vms_read_ar_hdr (%p)\n", abfd);
730 #endif
731 return NULL;
734 /* Provided a BFD, @var{archive}, containing an archive and NULL, open
735 an input BFD on the first contained element and returns that.
736 Subsequent calls should pass the archive and the previous return value
737 to return a created BFD to the next contained element.
738 NULL is returned when there are no more. */
740 static bfd *
741 vms_openr_next_archived_file (bfd *arch ATTRIBUTE_UNUSED,
742 bfd *prev ATTRIBUTE_UNUSED)
744 #if VMS_DEBUG
745 vms_debug (1, "vms_openr_next_archived_file (%p, %p)\n", arch, prev);
746 #endif
747 return NULL;
750 /* Return the BFD which is referenced by the symbol in ABFD indexed by
751 INDEX. INDEX should have been returned by bfd_get_next_mapent. */
753 static bfd *
754 vms_get_elt_at_index (bfd * abfd, symindex index)
756 #if VMS_DEBUG
757 vms_debug (1, "vms_get_elt_at_index (%p, %p)\n", abfd, index);
758 #endif
759 return _bfd_generic_get_elt_at_index (abfd, index);
762 /* ???
763 -> bfd_generic_stat_arch_elt. */
765 static int
766 vms_generic_stat_arch_elt (bfd * abfd, struct stat *st)
768 #if VMS_DEBUG
769 vms_debug (1, "vms_generic_stat_arch_elt (%p, %p)\n", abfd, st);
770 #endif
771 return bfd_generic_stat_arch_elt (abfd, st);
774 /* This is a new function in bfd 2.5. */
776 static bfd_boolean
777 vms_update_armap_timestamp (bfd * abfd ATTRIBUTE_UNUSED)
779 #if VMS_DEBUG
780 vms_debug (1, "vms_update_armap_timestamp (%p)\n", abfd);
781 #endif
782 return TRUE;
785 /* Part 4.5, symbols. */
787 /* Return the number of bytes required to store a vector of pointers
788 to asymbols for all the symbols in the BFD abfd, including a
789 terminal NULL pointer. If there are no symbols in the BFD,
790 then return 0. If an error occurs, return -1. */
792 static long
793 vms_get_symtab_upper_bound (bfd * abfd)
795 #if VMS_DEBUG
796 vms_debug (1, "vms_get_symtab_upper_bound (%p), %d symbols\n", abfd, PRIV (gsd_sym_count));
797 #endif
798 return (PRIV (gsd_sym_count) + 1) * sizeof (asymbol *);
801 /* Copy symbols from hash table to symbol vector
803 called from bfd_hash_traverse in vms_canonicalize_symtab
804 init counter to 0 if entry == 0. */
806 static bfd_boolean
807 copy_symbols (struct bfd_hash_entry *entry, void * arg)
809 bfd * abfd = (bfd *) arg;
811 if (entry == NULL) /* Init counter. */
812 PRIV (symnum) = 0;
813 else /* Fill vector, inc counter. */
814 PRIV (symcache)[PRIV (symnum)++] = ((vms_symbol_entry *)entry)->symbol;
816 return TRUE;
819 /* Read the symbols from the BFD abfd, and fills in the vector
820 location with pointers to the symbols and a trailing NULL.
822 Return number of symbols read. */
824 static long
825 vms_canonicalize_symtab (bfd * abfd, asymbol **symbols)
827 #if VMS_DEBUG
828 vms_debug (1, "vms_canonicalize_symtab (%p, <ret>)\n", abfd);
829 #endif
831 /* Init counter. */
832 copy_symbols (NULL, abfd);
834 /* Traverse table and fill symbols vector. */
835 PRIV (symcache) = symbols;
836 bfd_hash_traverse (PRIV (vms_symbol_table), copy_symbols, abfd);
838 symbols[PRIV (gsd_sym_count)] = NULL;
840 return PRIV (gsd_sym_count);
843 /* Print symbol to file according to how. how is one of
844 bfd_print_symbol_name just print the name
845 bfd_print_symbol_more print more (???)
846 bfd_print_symbol_all print all we know, which is not much right now :-). */
848 static void
849 vms_print_symbol (bfd * abfd,
850 void * file,
851 asymbol *symbol,
852 bfd_print_symbol_type how)
854 #if VMS_DEBUG
855 vms_debug (1, "vms_print_symbol (%p, %p, %p, %d)\n", abfd, file, symbol, how);
856 #endif
858 switch (how)
860 case bfd_print_symbol_name:
861 case bfd_print_symbol_more:
862 fprintf ((FILE *)file," %s", symbol->name);
863 break;
865 case bfd_print_symbol_all:
867 const char *section_name = symbol->section->name;
869 bfd_print_symbol_vandf (abfd, file, symbol);
871 fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
873 break;
877 /* Return information about symbol in ret.
879 fill type, value and name
880 type:
881 A absolute
882 B bss segment symbol
883 C common symbol
884 D data segment symbol
885 f filename
886 t a static function symbol
887 T text segment symbol
888 U undefined
889 - debug. */
891 static void
892 vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
893 asymbol *symbol,
894 symbol_info *ret)
896 asection *sec;
898 #if VMS_DEBUG
899 vms_debug (1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret);
900 #endif
902 sec = symbol->section;
904 if (ret == NULL)
905 return;
907 if (bfd_is_com_section (sec))
908 ret->type = 'C';
909 else if (bfd_is_abs_section (sec))
910 ret->type = 'A';
911 else if (bfd_is_und_section (sec))
912 ret->type = 'U';
913 else if (bfd_is_ind_section (sec))
914 ret->type = 'I';
915 else if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
916 ret->type = 'T';
917 else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
918 ret->type = 'D';
919 else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
920 ret->type = 'B';
921 else
922 ret->type = '-';
924 if (ret->type != 'U')
925 ret->value = symbol->value + symbol->section->vma;
926 else
927 ret->value = 0;
928 ret->name = symbol->name;
931 /* Return TRUE if the given symbol sym in the BFD abfd is
932 a compiler generated local label, else return FALSE. */
934 static bfd_boolean
935 vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
936 const char *name)
938 #if VMS_DEBUG
939 vms_debug (1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd, name);
940 #endif
941 return name[0] == '$';
944 /* Get source line number for symbol. */
946 static alent *
947 vms_get_lineno (bfd * abfd ATTRIBUTE_UNUSED,
948 asymbol *symbol ATTRIBUTE_UNUSED)
950 #if VMS_DEBUG
951 vms_debug (1, "vms_get_lineno (%p, %p)\n", abfd, symbol);
952 #endif
953 return NULL;
956 /* Provided a BFD, a section and an offset into the section, calculate and
957 return the name of the source file and the line nearest to the wanted
958 location. */
960 static bfd_boolean
961 vms_find_nearest_line (bfd * abfd ATTRIBUTE_UNUSED,
962 asection *section ATTRIBUTE_UNUSED,
963 asymbol **symbols ATTRIBUTE_UNUSED,
964 bfd_vma offset ATTRIBUTE_UNUSED,
965 const char **file ATTRIBUTE_UNUSED,
966 const char **func ATTRIBUTE_UNUSED,
967 unsigned int *line ATTRIBUTE_UNUSED)
969 #if VMS_DEBUG
970 vms_debug (1, "vms_find_nearest_line (%p, %s, %p, %ld, <ret>, <ret>, <ret>)\n",
971 abfd, section->name, symbols, (long int)offset);
972 #endif
973 return FALSE;
976 static bfd_boolean
977 vms_find_inliner_info (bfd * abfd ATTRIBUTE_UNUSED,
978 const char **file ATTRIBUTE_UNUSED,
979 const char **func ATTRIBUTE_UNUSED,
980 unsigned int *line ATTRIBUTE_UNUSED)
982 #if VMS_DEBUG
983 vms_debug (1, "vms_find_inliner_info (%p, <ret>, <ret>, <ret>)\n",
984 abfd);
985 #endif
986 return FALSE;
989 /* Back-door to allow format-aware applications to create debug symbols
990 while using BFD for everything else. Currently used by the assembler
991 when creating COFF files. */
993 static asymbol *
994 vms_bfd_make_debug_symbol (bfd * abfd ATTRIBUTE_UNUSED,
995 void *ptr ATTRIBUTE_UNUSED,
996 unsigned long size ATTRIBUTE_UNUSED)
998 #if VMS_DEBUG
999 vms_debug (1, "vms_bfd_make_debug_symbol (%p, %p, %ld)\n", abfd, ptr, size);
1000 #endif
1001 return NULL;
1004 /* Read minisymbols. For minisymbols, we use the unmodified a.out
1005 symbols. The minisymbol_to_symbol function translates these into
1006 BFD asymbol structures. */
1008 static long
1009 vms_read_minisymbols (bfd * abfd,
1010 bfd_boolean dynamic,
1011 void * *minisymsp,
1012 unsigned int *sizep)
1014 #if VMS_DEBUG
1015 vms_debug (1, "vms_read_minisymbols (%p, %d, %p, %d)\n", abfd, dynamic, minisymsp, *sizep);
1016 #endif
1017 return _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep);
1020 /* Convert a minisymbol to a BFD asymbol. A minisymbol is just an
1021 unmodified a.out symbol. The SYM argument is a structure returned
1022 by bfd_make_empty_symbol, which we fill in here. */
1024 static asymbol *
1025 vms_minisymbol_to_symbol (bfd * abfd,
1026 bfd_boolean dynamic,
1027 const void * minisym,
1028 asymbol *sym)
1030 #if VMS_DEBUG
1031 vms_debug (1, "vms_minisymbol_to_symbol (%p, %d, %p, %p)\n", abfd, dynamic, minisym, sym);
1032 #endif
1033 return _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym);
1036 /* Part 4.6, relocations. */
1038 /* Return the number of bytes required to store the relocation information
1039 associated with section sect attached to bfd abfd.
1040 If an error occurs, return -1. */
1042 static long
1043 vms_get_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED,
1044 asection *section ATTRIBUTE_UNUSED)
1046 #if VMS_DEBUG
1047 vms_debug (1, "vms_get_reloc_upper_bound (%p, %s)\n", abfd, section->name);
1048 #endif
1049 return -1L;
1052 /* Call the back end associated with the open BFD abfd and translate the
1053 external form of the relocation information attached to sec into the
1054 internal canonical form. Place the table into memory at loc, which has
1055 been preallocated, usually by a call to bfd_get_reloc_upper_bound.
1056 Returns the number of relocs, or -1 on error. */
1058 static long
1059 vms_canonicalize_reloc (bfd * abfd ATTRIBUTE_UNUSED,
1060 asection *section ATTRIBUTE_UNUSED,
1061 arelent **location ATTRIBUTE_UNUSED,
1062 asymbol **symbols ATTRIBUTE_UNUSED)
1064 #if VMS_DEBUG
1065 vms_debug (1, "vms_canonicalize_reloc (%p, %s, <ret>, <ret>)\n", abfd, section->name);
1066 #endif
1067 return FALSE;
1070 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
1072 /* How to process the various reloc types. */
1074 static bfd_reloc_status_type
1075 reloc_nil (bfd * abfd ATTRIBUTE_UNUSED,
1076 arelent *reloc ATTRIBUTE_UNUSED,
1077 asymbol *sym ATTRIBUTE_UNUSED,
1078 void * data ATTRIBUTE_UNUSED,
1079 asection *sec ATTRIBUTE_UNUSED,
1080 bfd *output_bfd ATTRIBUTE_UNUSED,
1081 char **error_message ATTRIBUTE_UNUSED)
1083 #if VMS_DEBUG
1084 vms_debug (1, "reloc_nil (abfd %p, output_bfd %p)\n", abfd, output_bfd);
1085 vms_debug (2, "In section %s, symbol %s\n",
1086 sec->name, sym->name);
1087 vms_debug (2, "reloc sym %s, addr %08lx, addend %08lx, reloc is a %s\n",
1088 reloc->sym_ptr_ptr[0]->name,
1089 (unsigned long)reloc->address,
1090 (unsigned long)reloc->addend, reloc->howto->name);
1091 vms_debug (2, "data at %p\n", data);
1092 /* _bfd_hexdump (2, data, bfd_get_reloc_size (reloc->howto), 0); */
1093 #endif
1095 return bfd_reloc_ok;
1098 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
1099 from smaller values. Start with zero, widen, *then* decrement. */
1100 #define MINUS_ONE (((bfd_vma)0) - 1)
1102 static reloc_howto_type alpha_howto_table[] =
1104 HOWTO (ALPHA_R_IGNORE, /* Type. */
1105 0, /* Rightshift. */
1106 0, /* Size (0 = byte, 1 = short, 2 = long). */
1107 8, /* Bitsize. */
1108 TRUE, /* PC relative. */
1109 0, /* Bitpos. */
1110 complain_overflow_dont,/* Complain_on_overflow. */
1111 reloc_nil, /* Special_function. */
1112 "IGNORE", /* Name. */
1113 TRUE, /* Partial_inplace. */
1114 0, /* Source mask */
1115 0, /* Dest mask. */
1116 TRUE), /* PC rel offset. */
1118 /* A 64 bit reference to a symbol. */
1119 HOWTO (ALPHA_R_REFQUAD, /* Type. */
1120 0, /* Rightshift. */
1121 4, /* Size (0 = byte, 1 = short, 2 = long). */
1122 64, /* Bitsize. */
1123 FALSE, /* PC relative. */
1124 0, /* Bitpos. */
1125 complain_overflow_bitfield, /* Complain_on_overflow. */
1126 reloc_nil, /* Special_function. */
1127 "REFQUAD", /* Name. */
1128 TRUE, /* Partial_inplace. */
1129 MINUS_ONE, /* Source mask. */
1130 MINUS_ONE, /* Dest mask. */
1131 FALSE), /* PC rel offset. */
1133 /* A 21 bit branch. The native assembler generates these for
1134 branches within the text segment, and also fills in the PC
1135 relative offset in the instruction. */
1136 HOWTO (ALPHA_R_BRADDR, /* Type. */
1137 2, /* Rightshift. */
1138 2, /* Size (0 = byte, 1 = short, 2 = long). */
1139 21, /* Bitsize. */
1140 TRUE, /* PC relative. */
1141 0, /* Bitpos. */
1142 complain_overflow_signed, /* Complain_on_overflow. */
1143 reloc_nil, /* Special_function. */
1144 "BRADDR", /* Name. */
1145 TRUE, /* Partial_inplace. */
1146 0x1fffff, /* Source mask. */
1147 0x1fffff, /* Dest mask. */
1148 FALSE), /* PC rel offset. */
1150 /* A hint for a jump to a register. */
1151 HOWTO (ALPHA_R_HINT, /* Type. */
1152 2, /* Rightshift. */
1153 1, /* Size (0 = byte, 1 = short, 2 = long). */
1154 14, /* Bitsize. */
1155 TRUE, /* PC relative. */
1156 0, /* Bitpos. */
1157 complain_overflow_dont,/* Complain_on_overflow. */
1158 reloc_nil, /* Special_function. */
1159 "HINT", /* Name. */
1160 TRUE, /* Partial_inplace. */
1161 0x3fff, /* Source mask. */
1162 0x3fff, /* Dest mask. */
1163 FALSE), /* PC rel offset. */
1165 /* 16 bit PC relative offset. */
1166 HOWTO (ALPHA_R_SREL16, /* Type. */
1167 0, /* Rightshift. */
1168 1, /* Size (0 = byte, 1 = short, 2 = long). */
1169 16, /* Bitsize. */
1170 TRUE, /* PC relative. */
1171 0, /* Bitpos. */
1172 complain_overflow_signed, /* Complain_on_overflow. */
1173 reloc_nil, /* Special_function. */
1174 "SREL16", /* Name. */
1175 TRUE, /* Partial_inplace. */
1176 0xffff, /* Source mask. */
1177 0xffff, /* Dest mask. */
1178 FALSE), /* PC rel offset. */
1180 /* 32 bit PC relative offset. */
1181 HOWTO (ALPHA_R_SREL32, /* Type. */
1182 0, /* Rightshift. */
1183 2, /* Size (0 = byte, 1 = short, 2 = long). */
1184 32, /* Bitsize. */
1185 TRUE, /* PC relative. */
1186 0, /* Bitpos. */
1187 complain_overflow_signed, /* Complain_on_overflow. */
1188 reloc_nil, /* Special_function. */
1189 "SREL32", /* Name. */
1190 TRUE, /* Partial_inplace. */
1191 0xffffffff, /* Source mask. */
1192 0xffffffff, /* Dest mask. */
1193 FALSE), /* PC rel offset. */
1195 /* A 64 bit PC relative offset. */
1196 HOWTO (ALPHA_R_SREL64, /* Type. */
1197 0, /* Rightshift. */
1198 4, /* Size (0 = byte, 1 = short, 2 = long). */
1199 64, /* Bitsize. */
1200 TRUE, /* PC relative. */
1201 0, /* Bitpos. */
1202 complain_overflow_signed, /* Complain_on_overflow. */
1203 reloc_nil, /* Special_function. */
1204 "SREL64", /* Name. */
1205 TRUE, /* Partial_inplace. */
1206 MINUS_ONE, /* Source mask. */
1207 MINUS_ONE, /* Dest mask. */
1208 FALSE), /* PC rel offset. */
1210 /* Push a value on the reloc evaluation stack. */
1211 HOWTO (ALPHA_R_OP_PUSH, /* Type. */
1212 0, /* Rightshift. */
1213 0, /* Size (0 = byte, 1 = short, 2 = long). */
1214 0, /* Bitsize. */
1215 FALSE, /* PC relative. */
1216 0, /* Bitpos. */
1217 complain_overflow_dont,/* Complain_on_overflow. */
1218 reloc_nil, /* Special_function. */
1219 "OP_PUSH", /* Name. */
1220 FALSE, /* Partial_inplace. */
1221 0, /* Source mask. */
1222 0, /* Dest mask. */
1223 FALSE), /* PC rel offset. */
1225 /* Store the value from the stack at the given address. Store it in
1226 a bitfield of size r_size starting at bit position r_offset. */
1227 HOWTO (ALPHA_R_OP_STORE, /* Type. */
1228 0, /* Rightshift. */
1229 4, /* Size (0 = byte, 1 = short, 2 = long). */
1230 64, /* Bitsize. */
1231 FALSE, /* PC relative. */
1232 0, /* Bitpos. */
1233 complain_overflow_dont,/* Complain_on_overflow. */
1234 reloc_nil, /* Special_function. */
1235 "OP_STORE", /* Name. */
1236 FALSE, /* Partial_inplace. */
1237 0, /* Source mask. */
1238 MINUS_ONE, /* Dest mask. */
1239 FALSE), /* PC rel offset. */
1241 /* Subtract the reloc address from the value on the top of the
1242 relocation stack. */
1243 HOWTO (ALPHA_R_OP_PSUB, /* Type. */
1244 0, /* Rightshift. */
1245 0, /* Size (0 = byte, 1 = short, 2 = long). */
1246 0, /* Bitsize. */
1247 FALSE, /* PC relative. */
1248 0, /* Bitpos. */
1249 complain_overflow_dont,/* Complain_on_overflow. */
1250 reloc_nil, /* Special_function. */
1251 "OP_PSUB", /* Name. */
1252 FALSE, /* Partial_inplace. */
1253 0, /* Source mask. */
1254 0, /* Dest mask. */
1255 FALSE), /* PC rel offset. */
1257 /* Shift the value on the top of the relocation stack right by the
1258 given value. */
1259 HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
1260 0, /* Rightshift. */
1261 0, /* Size (0 = byte, 1 = short, 2 = long). */
1262 0, /* Bitsize. */
1263 FALSE, /* PC relative. */
1264 0, /* Bitpos. */
1265 complain_overflow_dont,/* Complain_on_overflow. */
1266 reloc_nil, /* Special_function. */
1267 "OP_PRSHIFT", /* Name. */
1268 FALSE, /* Partial_inplace. */
1269 0, /* Source mask. */
1270 0, /* Dest mask. */
1271 FALSE), /* PC rel offset. */
1273 /* Hack. Linkage is done by linker. */
1274 HOWTO (ALPHA_R_LINKAGE, /* Type. */
1275 0, /* Rightshift. */
1276 8, /* Size (0 = byte, 1 = short, 2 = long). */
1277 256, /* Bitsize. */
1278 FALSE, /* PC relative. */
1279 0, /* Bitpos. */
1280 complain_overflow_dont,/* Complain_on_overflow. */
1281 reloc_nil, /* Special_function. */
1282 "LINKAGE", /* Name. */
1283 FALSE, /* Partial_inplace. */
1284 0, /* Source mask. */
1285 0, /* Dest mask. */
1286 FALSE), /* PC rel offset. */
1288 /* A 32 bit reference to a symbol. */
1289 HOWTO (ALPHA_R_REFLONG, /* Type. */
1290 0, /* Rightshift. */
1291 2, /* Size (0 = byte, 1 = short, 2 = long). */
1292 32, /* Bitsize. */
1293 FALSE, /* PC relative. */
1294 0, /* Bitpos. */
1295 complain_overflow_bitfield, /* Complain_on_overflow. */
1296 reloc_nil, /* Special_function. */
1297 "REFLONG", /* Name. */
1298 TRUE, /* Partial_inplace. */
1299 0xffffffff, /* Source mask. */
1300 0xffffffff, /* Dest mask. */
1301 FALSE), /* PC rel offset. */
1303 /* A 64 bit reference to a procedure, written as 32 bit value. */
1304 HOWTO (ALPHA_R_CODEADDR, /* Type. */
1305 0, /* Rightshift. */
1306 4, /* Size (0 = byte, 1 = short, 2 = long). */
1307 64, /* Bitsize. */
1308 FALSE, /* PC relative. */
1309 0, /* Bitpos. */
1310 complain_overflow_signed,/* Complain_on_overflow. */
1311 reloc_nil, /* Special_function. */
1312 "CODEADDR", /* Name. */
1313 FALSE, /* Partial_inplace. */
1314 0xffffffff, /* Source mask. */
1315 0xffffffff, /* Dest mask. */
1316 FALSE), /* PC rel offset. */
1320 /* Return a pointer to a howto structure which, when invoked, will perform
1321 the relocation code on data from the architecture noted. */
1323 static const struct reloc_howto_struct *
1324 vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
1325 bfd_reloc_code_real_type code)
1327 int alpha_type;
1329 #if VMS_DEBUG
1330 vms_debug (1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code);
1331 #endif
1333 switch (code)
1335 case BFD_RELOC_16: alpha_type = ALPHA_R_SREL16; break;
1336 case BFD_RELOC_32: alpha_type = ALPHA_R_REFLONG; break;
1337 case BFD_RELOC_64: alpha_type = ALPHA_R_REFQUAD; break;
1338 case BFD_RELOC_CTOR: alpha_type = ALPHA_R_REFQUAD; break;
1339 case BFD_RELOC_23_PCREL_S2: alpha_type = ALPHA_R_BRADDR; break;
1340 case BFD_RELOC_ALPHA_HINT: alpha_type = ALPHA_R_HINT; break;
1341 case BFD_RELOC_16_PCREL: alpha_type = ALPHA_R_SREL16; break;
1342 case BFD_RELOC_32_PCREL: alpha_type = ALPHA_R_SREL32; break;
1343 case BFD_RELOC_64_PCREL: alpha_type = ALPHA_R_SREL64; break;
1344 case BFD_RELOC_ALPHA_LINKAGE: alpha_type = ALPHA_R_LINKAGE; break;
1345 case BFD_RELOC_ALPHA_CODEADDR: alpha_type = ALPHA_R_CODEADDR; break;
1346 default:
1347 (*_bfd_error_handler) ("reloc (%d) is *UNKNOWN*", code);
1348 return NULL;
1350 #if VMS_DEBUG
1351 vms_debug (2, "reloc is %s\n", alpha_howto_table[alpha_type].name);
1352 #endif
1353 return & alpha_howto_table[alpha_type];
1356 /* Part 4.7, writing an object file. */
1358 /* Set the architecture and machine type in BFD abfd to arch and mach.
1359 Find the correct pointer to a structure and insert it into the arch_info
1360 pointer. */
1362 static bfd_boolean
1363 vms_set_arch_mach (bfd * abfd,
1364 enum bfd_architecture arch ATTRIBUTE_UNUSED,
1365 unsigned long mach ATTRIBUTE_UNUSED)
1367 #if VMS_DEBUG
1368 vms_debug (1, "vms_set_arch_mach (%p, %d, %ld)\n", abfd, arch, mach);
1369 #endif
1370 abfd->arch_info = bfd_scan_arch ("alpha");
1372 return TRUE;
1375 /* Sets the contents of the section section in BFD abfd to the data starting
1376 in memory at data. The data is written to the output section starting at
1377 offset offset for count bytes.
1379 Normally TRUE is returned, else FALSE. Possible error returns are:
1380 o bfd_error_no_contents - The output section does not have the
1381 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1382 o and some more too */
1384 static bfd_boolean
1385 vms_set_section_contents (bfd * abfd,
1386 asection *section,
1387 const void * location,
1388 file_ptr offset,
1389 bfd_size_type count)
1391 #if VMS_DEBUG
1392 vms_debug (1, "vms_set_section_contents (%p, sec %s, loc %p, off %ld, count %d)\n",
1393 abfd, section->name, location, (long int)offset, (int)count);
1394 vms_debug (2, "size %d\n", (int) section->size);
1395 #endif
1396 return _bfd_save_vms_section (abfd, section, location, offset, count);
1399 /* Part 4.8, linker. */
1401 /* Get the size of the section headers. */
1403 static int
1404 vms_sizeof_headers (bfd * abfd ATTRIBUTE_UNUSED,
1405 struct bfd_link_info *info ATTRIBUTE_UNUSED)
1407 #if VMS_DEBUG
1408 vms_debug (1, "vms_sizeof_headers (%p, %s)\n", abfd, (reloc)?"True":"False");
1409 #endif
1410 return 0;
1413 /* Provides default handling of relocation effort for back ends
1414 which can't be bothered to do it efficiently. */
1416 static bfd_byte *
1417 vms_bfd_get_relocated_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
1418 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1419 struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
1420 bfd_byte *data ATTRIBUTE_UNUSED,
1421 bfd_boolean relocatable ATTRIBUTE_UNUSED,
1422 asymbol **symbols ATTRIBUTE_UNUSED)
1424 #if VMS_DEBUG
1425 vms_debug (1, "vms_bfd_get_relocated_section_contents (%p, %p, %p, %p, %s, %p)\n",
1426 abfd, link_info, link_order, data, (relocatable)?"True":"False", symbols);
1427 #endif
1428 return NULL;
1431 /* ??? */
1433 static bfd_boolean
1434 vms_bfd_relax_section (bfd * abfd ATTRIBUTE_UNUSED,
1435 asection *section ATTRIBUTE_UNUSED,
1436 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1437 bfd_boolean *again ATTRIBUTE_UNUSED)
1439 #if VMS_DEBUG
1440 vms_debug (1, "vms_bfd_relax_section (%p, %s, %p, <ret>)\n",
1441 abfd, section->name, link_info);
1442 #endif
1443 return TRUE;
1446 static bfd_boolean
1447 vms_bfd_gc_sections (bfd * abfd ATTRIBUTE_UNUSED,
1448 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1450 #if VMS_DEBUG
1451 vms_debug (1, "vms_bfd_gc_sections (%p, %p)\n", abfd, link_info);
1452 #endif
1453 return TRUE;
1456 static bfd_boolean
1457 vms_bfd_merge_sections (bfd * abfd ATTRIBUTE_UNUSED,
1458 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1460 #if VMS_DEBUG
1461 vms_debug (1, "vms_bfd_merge_sections (%p, %p)\n", abfd, link_info);
1462 #endif
1463 return TRUE;
1466 /* Create a hash table for the linker. Different backends store
1467 different information in this table. */
1469 static struct bfd_link_hash_table *
1470 vms_bfd_link_hash_table_create (bfd * abfd ATTRIBUTE_UNUSED)
1472 #if VMS_DEBUG
1473 vms_debug (1, "vms_bfd_link_hash_table_create (%p)\n", abfd);
1474 #endif
1475 return NULL;
1478 /* Free a linker hash table. */
1480 static void
1481 vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED)
1483 #if VMS_DEBUG
1484 vms_debug (1, "vms_bfd_link_hash_table_free (%p)\n", abfd);
1485 #endif
1488 /* Add symbols from this object file into the hash table. */
1490 static bfd_boolean
1491 vms_bfd_link_add_symbols (bfd * abfd ATTRIBUTE_UNUSED,
1492 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1494 #if VMS_DEBUG
1495 vms_debug (1, "vms_bfd_link_add_symbols (%p, %p)\n", abfd, link_info);
1496 #endif
1497 return FALSE;
1500 /* Do a link based on the link_order structures attached to each
1501 section of the BFD. */
1503 static bfd_boolean
1504 vms_bfd_final_link (bfd * abfd ATTRIBUTE_UNUSED,
1505 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1507 #if VMS_DEBUG
1508 vms_debug (1, "vms_bfd_final_link (%p, %p)\n", abfd, link_info);
1509 #endif
1510 return TRUE;
1513 /* Should this section be split up into smaller pieces during linking. */
1515 static bfd_boolean
1516 vms_bfd_link_split_section (bfd * abfd ATTRIBUTE_UNUSED,
1517 asection *section ATTRIBUTE_UNUSED)
1519 #if VMS_DEBUG
1520 vms_debug (1, "vms_bfd_link_split_section (%p, %s)\n", abfd, section->name);
1521 #endif
1522 return FALSE;
1525 /* Part 4.9, dynamic symbols and relocations. */
1527 /* Get the amount of memory required to hold the dynamic symbols. */
1529 static long
1530 vms_get_dynamic_symtab_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
1532 #if VMS_DEBUG
1533 vms_debug (1, "vms_get_dynamic_symtab_upper_bound (%p)\n", abfd);
1534 #endif
1535 return 0;
1538 static bfd_boolean
1539 vms_bfd_print_private_bfd_data (bfd * abfd ATTRIBUTE_UNUSED,
1540 void *file ATTRIBUTE_UNUSED)
1542 #if VMS_DEBUG
1543 vms_debug (1, "vms_bfd_print_private_bfd_data (%p)\n", abfd);
1544 #endif
1545 return FALSE;
1548 /* Read in the dynamic symbols. */
1550 static long
1551 vms_canonicalize_dynamic_symtab (bfd * abfd ATTRIBUTE_UNUSED,
1552 asymbol **symbols ATTRIBUTE_UNUSED)
1554 #if VMS_DEBUG
1555 vms_debug (1, "vms_canonicalize_dynamic_symtab (%p, <ret>)\n", abfd);
1556 #endif
1557 return 0L;
1560 /* Get the amount of memory required to hold the dynamic relocs. */
1562 static long
1563 vms_get_dynamic_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
1565 #if VMS_DEBUG
1566 vms_debug (1, "vms_get_dynamic_reloc_upper_bound (%p)\n", abfd);
1567 #endif
1568 return 0L;
1571 /* Read in the dynamic relocs. */
1573 static long
1574 vms_canonicalize_dynamic_reloc (bfd * abfd ATTRIBUTE_UNUSED,
1575 arelent **arel ATTRIBUTE_UNUSED,
1576 asymbol **symbols ATTRIBUTE_UNUSED)
1578 #if VMS_DEBUG
1579 vms_debug (1, "vms_canonicalize_dynamic_reloc (%p)\n", abfd);
1580 #endif
1581 return 0L;
1584 const bfd_target vms_alpha_vec =
1586 "vms-alpha", /* Name. */
1587 bfd_target_evax_flavour,
1588 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
1589 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
1591 (HAS_RELOC | HAS_SYMS
1592 | WP_TEXT | D_PAGED), /* Object flags. */
1593 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
1594 | SEC_READONLY | SEC_CODE | SEC_DATA
1595 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
1596 0, /* Symbol_leading_char. */
1597 ' ', /* AR_pad_char. */
1598 15, /* AR_max_namelen. */
1599 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1600 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1601 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
1602 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1603 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1604 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
1606 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
1607 vms_archive_p, _bfd_dummy_target},
1608 {bfd_false, vms_mkobject, /* bfd_set_format. */
1609 _bfd_generic_mkarchive, bfd_false},
1610 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
1611 _bfd_write_archive_contents, bfd_false},
1613 BFD_JUMP_TABLE_GENERIC (vms),
1614 BFD_JUMP_TABLE_COPY (vms),
1615 BFD_JUMP_TABLE_CORE (vms),
1616 BFD_JUMP_TABLE_ARCHIVE (vms),
1617 BFD_JUMP_TABLE_SYMBOLS (vms),
1618 BFD_JUMP_TABLE_RELOCS (vms),
1619 BFD_JUMP_TABLE_WRITE (vms),
1620 BFD_JUMP_TABLE_LINK (vms),
1621 BFD_JUMP_TABLE_DYNAMIC (vms),
1623 NULL,
1625 NULL
1628 const bfd_target vms_vax_vec =
1630 "vms-vax", /* Name. */
1631 bfd_target_ovax_flavour,
1632 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
1633 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
1635 (HAS_RELOC | HAS_SYMS /* Object flags. */
1636 | WP_TEXT | D_PAGED
1637 | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
1639 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
1640 | SEC_READONLY | SEC_CODE | SEC_DATA
1641 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
1642 0, /* Symbol_leading_char. */
1643 ' ', /* AR_pad_char. */
1644 15, /* AR_max_namelen. */
1645 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1646 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1647 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
1648 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1649 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1650 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */
1652 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
1653 vms_archive_p, _bfd_dummy_target},
1654 {bfd_false, vms_mkobject, /* bfd_set_format. */
1655 _bfd_generic_mkarchive, bfd_false},
1656 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
1657 _bfd_write_archive_contents, bfd_false},
1659 BFD_JUMP_TABLE_GENERIC (vms),
1660 BFD_JUMP_TABLE_COPY (vms),
1661 BFD_JUMP_TABLE_CORE (vms),
1662 BFD_JUMP_TABLE_ARCHIVE (vms),
1663 BFD_JUMP_TABLE_SYMBOLS (vms),
1664 BFD_JUMP_TABLE_RELOCS (vms),
1665 BFD_JUMP_TABLE_WRITE (vms),
1666 BFD_JUMP_TABLE_LINK (vms),
1667 BFD_JUMP_TABLE_DYNAMIC (vms),
1669 NULL,
1671 NULL