]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - bfd/vms.c
bfd/
[thirdparty/binutils-gdb.git] / bfd / vms.c
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 Free Software Foundation, Inc.
5
6 Written by Klaus K"ampf (kkaempf@rmi.de)
7
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.
12
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.
17
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. */
21
22 #include "sysdep.h"
23 #include "bfd.h"
24 #include "bfdlink.h"
25 #include "libbfd.h"
26
27 #include "vms.h"
28
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
37
38 static unsigned int priv_section_count;
39 extern const bfd_target vms_vax_vec;
40 extern const bfd_target vms_alpha_vec;
41 \f
42 /* Initialize private data. */
43
44 static bfd_boolean
45 vms_initialize (bfd * abfd)
46 {
47 int i;
48 bfd_size_type amt;
49
50 bfd_set_start_address (abfd, (bfd_vma) -1);
51
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;
56
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;
68
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;
74
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;
79
80 if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc,
81 sizeof (vms_symbol_entry)))
82 goto error_ret1;
83
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;
88
89 for (i = 0; i < VMS_SECTION_COUNT; i++)
90 PRIV (vms_section_table)[i] = NULL;
91
92 amt = MAX_OUTREC_SIZE;
93 PRIV (output_buf) = bfd_alloc (abfd, amt);
94 if (PRIV (output_buf) == NULL)
95 goto error_ret2;
96
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;
102
103 return TRUE;
104
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;
111 }
112
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.
117
118 It has the correct value for referenced (undefined section) symbols
119
120 called from bfd_hash_traverse in vms_fixup_sections. */
121
122 static bfd_boolean
123 fill_section_ptr (struct bfd_hash_entry * entry, void * sections)
124 {
125 asection *sec;
126 asymbol *sym;
127
128 sym = ((vms_symbol_entry *) entry)->symbol;
129 sec = sym->section;
130
131 #if VMS_DEBUG
132 vms_debug (6, "fill_section_ptr: sym %p, sec %p\n", sym, sec);
133 #endif
134
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];
139
140 if (strcmp (sym->name, sec->name) == 0)
141 sym->flags |= BSF_SECTION_SYM;
142
143 return TRUE;
144 }
145
146 /* Fixup sections
147 set up all pointers and arrays, counters and sizes are fixed now
148
149 we build a private sections vector for easy access since sections
150 are always referenced by an index number.
151
152 alloc PRIV(sections) according to abfd->section_count
153 copy abfd->sections to PRIV(sections). */
154
155 static bfd_boolean
156 vms_fixup_sections (bfd * abfd)
157 {
158 if (PRIV (fixup_done))
159 return TRUE;
160
161 /* Traverse symbol table and fill in all section pointers. */
162
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)));
166
167 PRIV (fixup_done) = TRUE;
168
169 return TRUE;
170 }
171 \f
172 /* Check the format for a file being read.
173 Return a (bfd_target *) if it's an object file or zero if not. */
174
175 static const struct bfd_target *
176 vms_object_p (bfd * abfd)
177 {
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);
184
185 #if VMS_DEBUG
186 vms_debug (1, "vms_object_p (%p)\n", abfd);
187 #endif
188
189 if (!vms_initialize (abfd))
190 goto error_ret;
191
192 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
193 goto err_wrong_format;
194
195 prev_type = -1;
196
197 do
198 {
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)
203 {
204 #if VMS_DEBUG
205 vms_debug (2, "next_record failed\n");
206 #endif
207 goto err_wrong_format;
208 }
209
210 if ((prev_type == EOBJ_S_C_EGSD)
211 && (PRIV (rec_type) != EOBJ_S_C_EGSD))
212 {
213 if (! vms_fixup_sections (abfd))
214 {
215 #if VMS_DEBUG
216 vms_debug (2, "vms_fixup_sections failed\n");
217 #endif
218 goto err_wrong_format;
219 }
220 }
221
222 prev_type = PRIV (rec_type);
223
224 if (target_vector == NULL)
225 {
226 if (prev_type <= OBJ_S_C_MAXRECTYP)
227 target_vector = & vms_vax_vec;
228 else
229 target_vector = & vms_alpha_vec;
230 }
231
232 switch (prev_type)
233 {
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;
264 }
265 if (err != 0)
266 {
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;
271 }
272 }
273 while ((prev_type != EOBJ_S_C_EEOM) && (prev_type != OBJ_S_C_EOM) && (prev_type != OBJ_S_C_EOMW));
274
275 if (target_vector == & vms_vax_vec)
276 {
277 if (! vms_fixup_sections (abfd))
278 {
279 #if VMS_DEBUG
280 vms_debug (2, "vms_fixup_sections failed\n");
281 #endif
282 goto err_wrong_format;
283 }
284
285 /* Set arch_info to vax. */
286
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
292 }
293 else if (target_vector == & vms_alpha_vec)
294 {
295 /* Set arch_info to alpha. */
296
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
302 }
303
304 if (arch == NULL)
305 {
306 #if VMS_DEBUG
307 vms_debug (2, "arch not found\n");
308 #endif
309 goto err_wrong_format;
310 }
311 abfd->arch_info = arch;
312
313 return target_vector;
314
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;
323 }
324
325 /* Check the format for a file being read.
326 Return a (bfd_target *) if it's an archive file or zero. */
327
328 static const struct bfd_target *
329 vms_archive_p (bfd * abfd ATTRIBUTE_UNUSED)
330 {
331 #if VMS_DEBUG
332 vms_debug (1, "vms_archive_p (%p)\n", abfd);
333 #endif
334
335 return NULL;
336 }
337
338 /* Set the format of a file being written. */
339
340 static bfd_boolean
341 vms_mkobject (bfd * abfd)
342 {
343 #if VMS_DEBUG
344 vms_debug (1, "vms_mkobject (%p)\n", abfd);
345 #endif
346
347 if (!vms_initialize (abfd))
348 return FALSE;
349
350 {
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)
357 {
358 bfd_set_error (bfd_error_wrong_format);
359 return FALSE;
360 }
361 abfd->arch_info = arch;
362 }
363
364 return TRUE;
365 }
366
367 /* Write cached information into a file being written, at bfd_close. */
368
369 static bfd_boolean
370 vms_write_object_contents (bfd * abfd)
371 {
372 #if VMS_DEBUG
373 vms_debug (1, "vms_write_object_contents (%p)\n", abfd);
374 #endif
375
376 if (abfd->section_count > 0) /* we have sections */
377 {
378 if (PRIV (is_vax))
379 {
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)
391 {
392 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOMW) != 0)
393 return FALSE;
394 }
395 else
396 {
397 if (_bfd_vms_write_eom (abfd, OBJ_S_C_EOM) != 0)
398 return FALSE;
399 }
400 }
401 else
402 {
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;
415 }
416 }
417 return TRUE;
418 }
419
420 /* 4.1, generic. */
421
422 /* Called when the BFD is being closed to do any necessary cleanup. */
423
424 static bfd_boolean
425 vms_close_and_cleanup (bfd * abfd)
426 {
427 #if VMS_DEBUG
428 vms_debug (1, "vms_close_and_cleanup (%p)\n", abfd);
429 #endif
430 if (abfd == NULL)
431 return TRUE;
432
433 if (PRIV (vms_buf) != NULL)
434 free (PRIV (vms_buf));
435
436 if (PRIV (sections) != NULL)
437 free (PRIV (sections));
438
439 if (PRIV (vms_symbol_table))
440 bfd_hash_table_free (PRIV (vms_symbol_table));
441
442 bfd_release (abfd, abfd->tdata.any);
443 abfd->tdata.any = NULL;
444
445 return TRUE;
446 }
447
448 /* Ask the BFD to free all cached information. */
449
450 static bfd_boolean
451 vms_bfd_free_cached_info (bfd * abfd ATTRIBUTE_UNUSED)
452 {
453 #if VMS_DEBUG
454 vms_debug (1, "vms_bfd_free_cached_info (%p)\n", abfd);
455 #endif
456 return TRUE;
457 }
458
459 /* Called when a new section is created. */
460
461 static bfd_boolean
462 vms_new_section_hook (bfd * abfd, asection *section)
463 {
464 /* Count hasn't been incremented yet. */
465 unsigned int section_count = abfd->section_count + 1;
466
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);
472
473 if (section_count > PRIV (section_count))
474 {
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;
481 }
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
489
490 return _bfd_generic_new_section_hook (abfd, section);
491 }
492
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) */
496
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)
503 {
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
508
509 /* Shouldn't be called, since all sections are IN_MEMORY. */
510 return FALSE;
511 }
512
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). */
516
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)
523 {
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
528
529 /* Shouldn't be called, since all sections are IN_MEMORY. */
530 return FALSE;
531 }
532
533 /* Part 4.2, copy private data. */
534
535 /* Called to copy BFD general private data from one object file
536 to another. */
537
538 static bfd_boolean
539 vms_bfd_copy_private_bfd_data (bfd *src ATTRIBUTE_UNUSED,
540 bfd *dest ATTRIBUTE_UNUSED)
541 {
542 #if VMS_DEBUG
543 vms_debug (1, "vms_bfd_copy_private_bfd_data (%p, %p)\n", src, dest);
544 #endif
545 return TRUE;
546 }
547
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:
551
552 o <<bfd_error_no_memory>> -
553 Not enough memory exists to create private data for @var{obfd}. */
554
555 static bfd_boolean
556 vms_bfd_merge_private_bfd_data (bfd * ibfd ATTRIBUTE_UNUSED,
557 bfd * obfd ATTRIBUTE_UNUSED)
558 {
559 #if VMS_DEBUG
560 vms_debug (1,"vms_bfd_merge_private_bfd_data (%p, %p)\n", ibfd, obfd);
561 #endif
562 return TRUE;
563 }
564
565 /* Set private BFD flag information in the BFD @var{abfd}.
566 Return <<TRUE>> on success, <<FALSE>> on error. Possible error
567 returns are:
568
569 o <<bfd_error_no_memory>> -
570 Not enough memory exists to create private data for @var{obfd}. */
571
572 static bfd_boolean
573 vms_bfd_set_private_flags (bfd * abfd ATTRIBUTE_UNUSED,
574 flagword flags ATTRIBUTE_UNUSED)
575 {
576 #if VMS_DEBUG
577 vms_debug (1,"vms_bfd_set_private_flags (%p, %lx)\n", abfd, (long)flags);
578 #endif
579 return TRUE;
580 }
581
582 /* Called to copy BFD private section data from one object file
583 to another. */
584
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)
590 {
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;
596 }
597
598 /* Called to copy BFD private symbol data from one object file
599 to another. */
600
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)
606 {
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;
612 }
613
614 /* Part 4.3, core file. */
615
616 /* Return a read-only string explaining which program was running
617 when it failed and produced the core file abfd. */
618
619 static char *
620 vms_core_file_failing_command (bfd * abfd ATTRIBUTE_UNUSED)
621 {
622 #if VMS_DEBUG
623 vms_debug (1, "vms_core_file_failing_command (%p)\n", abfd);
624 #endif
625 return NULL;
626 }
627
628 /* Returns the signal number which caused the core dump which
629 generated the file the BFD abfd is attached to. */
630
631 static int
632 vms_core_file_failing_signal (bfd * abfd ATTRIBUTE_UNUSED)
633 {
634 #if VMS_DEBUG
635 vms_debug (1, "vms_core_file_failing_signal (%p)\n", abfd);
636 #endif
637 return 0;
638 }
639
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. */
642
643 static bfd_boolean
644 vms_core_file_matches_executable_p (bfd * abfd ATTRIBUTE_UNUSED,
645 bfd *bbfd ATTRIBUTE_UNUSED)
646 {
647 #if VMS_DEBUG
648 vms_debug (1, "vms_core_file_matches_executable_p (%p, %p)\n", abfd, bbfd);
649 #endif
650 return FALSE;
651 }
652
653 /* Part 4.4, archive. */
654
655 /* ??? do something with an archive map.
656 Return FALSE on error, TRUE otherwise. */
657
658 static bfd_boolean
659 vms_slurp_armap (bfd * abfd ATTRIBUTE_UNUSED)
660 {
661 #if VMS_DEBUG
662 vms_debug (1, "vms_slurp_armap (%p)\n", abfd);
663 #endif
664 return FALSE;
665 }
666
667 /* ??? do something with an extended name table.
668 Return FALSE on error, TRUE otherwise. */
669
670 static bfd_boolean
671 vms_slurp_extended_name_table (bfd * abfd ATTRIBUTE_UNUSED)
672 {
673 #if VMS_DEBUG
674 vms_debug (1, "vms_slurp_extended_name_table (%p)\n", abfd);
675 #endif
676 return FALSE;
677 }
678
679 /* ??? do something with an extended name table.
680 Return FALSE on error, TRUE otherwise. */
681
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)
687 {
688 #if VMS_DEBUG
689 vms_debug (1, "vms_construct_extended_name_table (%p)\n", abfd);
690 #endif
691 return FALSE;
692 }
693
694 /* Truncate the name of an archive to match system-dependent restrictions. */
695
696 static void
697 vms_truncate_arname (bfd * abfd ATTRIBUTE_UNUSED,
698 const char *pathname ATTRIBUTE_UNUSED,
699 char *arhdr ATTRIBUTE_UNUSED)
700 {
701 #if VMS_DEBUG
702 vms_debug (1, "vms_truncate_arname (%p, %s, %s)\n", abfd, pathname, arhdr);
703 #endif
704 return;
705 }
706
707 /* ??? write archive map. */
708
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)
715 {
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;
721 }
722
723 /* Read archive header ??? */
724
725 static void *
726 vms_read_ar_hdr (bfd * abfd ATTRIBUTE_UNUSED)
727 {
728 #if VMS_DEBUG
729 vms_debug (1, "vms_read_ar_hdr (%p)\n", abfd);
730 #endif
731 return NULL;
732 }
733
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. */
739
740 static bfd *
741 vms_openr_next_archived_file (bfd *arch ATTRIBUTE_UNUSED,
742 bfd *prev ATTRIBUTE_UNUSED)
743 {
744 #if VMS_DEBUG
745 vms_debug (1, "vms_openr_next_archived_file (%p, %p)\n", arch, prev);
746 #endif
747 return NULL;
748 }
749
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. */
752
753 static bfd *
754 vms_get_elt_at_index (bfd * abfd, symindex index)
755 {
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);
760 }
761
762 /* ???
763 -> bfd_generic_stat_arch_elt. */
764
765 static int
766 vms_generic_stat_arch_elt (bfd * abfd, struct stat *st)
767 {
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);
772 }
773
774 /* This is a new function in bfd 2.5. */
775
776 static bfd_boolean
777 vms_update_armap_timestamp (bfd * abfd ATTRIBUTE_UNUSED)
778 {
779 #if VMS_DEBUG
780 vms_debug (1, "vms_update_armap_timestamp (%p)\n", abfd);
781 #endif
782 return TRUE;
783 }
784
785 /* Part 4.5, symbols. */
786
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. */
791
792 static long
793 vms_get_symtab_upper_bound (bfd * abfd)
794 {
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 *);
799 }
800
801 /* Copy symbols from hash table to symbol vector
802
803 called from bfd_hash_traverse in vms_canonicalize_symtab
804 init counter to 0 if entry == 0. */
805
806 static bfd_boolean
807 copy_symbols (struct bfd_hash_entry *entry, void * arg)
808 {
809 bfd * abfd = (bfd *) arg;
810
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;
815
816 return TRUE;
817 }
818
819 /* Read the symbols from the BFD abfd, and fills in the vector
820 location with pointers to the symbols and a trailing NULL.
821
822 Return number of symbols read. */
823
824 static long
825 vms_canonicalize_symtab (bfd * abfd, asymbol **symbols)
826 {
827 #if VMS_DEBUG
828 vms_debug (1, "vms_canonicalize_symtab (%p, <ret>)\n", abfd);
829 #endif
830
831 /* Init counter. */
832 copy_symbols (NULL, abfd);
833
834 /* Traverse table and fill symbols vector. */
835 PRIV (symcache) = symbols;
836 bfd_hash_traverse (PRIV (vms_symbol_table), copy_symbols, abfd);
837
838 symbols[PRIV (gsd_sym_count)] = NULL;
839
840 return PRIV (gsd_sym_count);
841 }
842
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 :-). */
847
848 static void
849 vms_print_symbol (bfd * abfd,
850 void * file,
851 asymbol *symbol,
852 bfd_print_symbol_type how)
853 {
854 #if VMS_DEBUG
855 vms_debug (1, "vms_print_symbol (%p, %p, %p, %d)\n", abfd, file, symbol, how);
856 #endif
857
858 switch (how)
859 {
860 case bfd_print_symbol_name:
861 case bfd_print_symbol_more:
862 fprintf ((FILE *)file," %s", symbol->name);
863 break;
864
865 case bfd_print_symbol_all:
866 {
867 const char *section_name = symbol->section->name;
868
869 bfd_print_symbol_vandf (abfd, file, symbol);
870
871 fprintf ((FILE *) file," %-8s %s", section_name, symbol->name);
872 }
873 break;
874 }
875 }
876
877 /* Return information about symbol in ret.
878
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. */
890
891 static void
892 vms_get_symbol_info (bfd * abfd ATTRIBUTE_UNUSED,
893 asymbol *symbol,
894 symbol_info *ret)
895 {
896 asection *sec;
897
898 #if VMS_DEBUG
899 vms_debug (1, "vms_get_symbol_info (%p, %p, %p)\n", abfd, symbol, ret);
900 #endif
901
902 sec = symbol->section;
903
904 if (ret == NULL)
905 return;
906
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 = '-';
923
924 if (ret->type != 'U')
925 ret->value = symbol->value + symbol->section->vma;
926 else
927 ret->value = 0;
928 ret->name = symbol->name;
929 }
930
931 /* Return TRUE if the given symbol sym in the BFD abfd is
932 a compiler generated local label, else return FALSE. */
933
934 static bfd_boolean
935 vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
936 const char *name)
937 {
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] == '$';
942 }
943
944 /* Get source line number for symbol. */
945
946 static alent *
947 vms_get_lineno (bfd * abfd ATTRIBUTE_UNUSED,
948 asymbol *symbol ATTRIBUTE_UNUSED)
949 {
950 #if VMS_DEBUG
951 vms_debug (1, "vms_get_lineno (%p, %p)\n", abfd, symbol);
952 #endif
953 return NULL;
954 }
955
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. */
959
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)
968 {
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;
974 }
975
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)
981 {
982 #if VMS_DEBUG
983 vms_debug (1, "vms_find_inliner_info (%p, <ret>, <ret>, <ret>)\n",
984 abfd);
985 #endif
986 return FALSE;
987 }
988
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. */
992
993 static asymbol *
994 vms_bfd_make_debug_symbol (bfd * abfd ATTRIBUTE_UNUSED,
995 void *ptr ATTRIBUTE_UNUSED,
996 unsigned long size ATTRIBUTE_UNUSED)
997 {
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;
1002 }
1003
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. */
1007
1008 static long
1009 vms_read_minisymbols (bfd * abfd,
1010 bfd_boolean dynamic,
1011 void * *minisymsp,
1012 unsigned int *sizep)
1013 {
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);
1018 }
1019
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. */
1023
1024 static asymbol *
1025 vms_minisymbol_to_symbol (bfd * abfd,
1026 bfd_boolean dynamic,
1027 const void * minisym,
1028 asymbol *sym)
1029 {
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);
1034 }
1035
1036 /* Part 4.6, relocations. */
1037
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. */
1041
1042 static long
1043 vms_get_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED,
1044 asection *section ATTRIBUTE_UNUSED)
1045 {
1046 #if VMS_DEBUG
1047 vms_debug (1, "vms_get_reloc_upper_bound (%p, %s)\n", abfd, section->name);
1048 #endif
1049 return -1L;
1050 }
1051
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. */
1057
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)
1063 {
1064 #if VMS_DEBUG
1065 vms_debug (1, "vms_canonicalize_reloc (%p, %s, <ret>, <ret>)\n", abfd, section->name);
1066 #endif
1067 return FALSE;
1068 }
1069 \f
1070 /* This is just copied from ecoff-alpha, needs to be fixed probably. */
1071
1072 /* How to process the various reloc types. */
1073
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)
1082 {
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
1094
1095 return bfd_reloc_ok;
1096 }
1097
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)
1101
1102 static reloc_howto_type alpha_howto_table[] =
1103 {
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. */
1117
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. */
1132
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. */
1149
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. */
1164
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. */
1179
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. */
1194
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. */
1209
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. */
1224
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. */
1240
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. */
1256
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. */
1272
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. */
1287
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. */
1302
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. */
1317
1318 };
1319
1320 /* Return a pointer to a howto structure which, when invoked, will perform
1321 the relocation code on data from the architecture noted. */
1322
1323 static const struct reloc_howto_struct *
1324 vms_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
1325 bfd_reloc_code_real_type code)
1326 {
1327 int alpha_type;
1328
1329 #if VMS_DEBUG
1330 vms_debug (1, "vms_bfd_reloc_type_lookup (%p, %d)\t", abfd, code);
1331 #endif
1332
1333 switch (code)
1334 {
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;
1349 }
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];
1354 }
1355
1356 static reloc_howto_type *
1357 vms_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1358 const char *r_name)
1359 {
1360 unsigned int i;
1361
1362 for (i = 0;
1363 i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
1364 i++)
1365 if (alpha_howto_table[i].name != NULL
1366 && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
1367 return &alpha_howto_table[i];
1368
1369 return NULL;
1370 }
1371
1372 /* Part 4.7, writing an object file. */
1373
1374 /* Set the architecture and machine type in BFD abfd to arch and mach.
1375 Find the correct pointer to a structure and insert it into the arch_info
1376 pointer. */
1377
1378 static bfd_boolean
1379 vms_set_arch_mach (bfd * abfd,
1380 enum bfd_architecture arch ATTRIBUTE_UNUSED,
1381 unsigned long mach ATTRIBUTE_UNUSED)
1382 {
1383 #if VMS_DEBUG
1384 vms_debug (1, "vms_set_arch_mach (%p, %d, %ld)\n", abfd, arch, mach);
1385 #endif
1386 abfd->arch_info = bfd_scan_arch ("alpha");
1387
1388 return TRUE;
1389 }
1390
1391 /* Sets the contents of the section section in BFD abfd to the data starting
1392 in memory at data. The data is written to the output section starting at
1393 offset offset for count bytes.
1394
1395 Normally TRUE is returned, else FALSE. Possible error returns are:
1396 o bfd_error_no_contents - The output section does not have the
1397 SEC_HAS_CONTENTS attribute, so nothing can be written to it.
1398 o and some more too */
1399
1400 static bfd_boolean
1401 vms_set_section_contents (bfd * abfd,
1402 asection *section,
1403 const void * location,
1404 file_ptr offset,
1405 bfd_size_type count)
1406 {
1407 #if VMS_DEBUG
1408 vms_debug (1, "vms_set_section_contents (%p, sec %s, loc %p, off %ld, count %d)\n",
1409 abfd, section->name, location, (long int)offset, (int)count);
1410 vms_debug (2, "size %d\n", (int) section->size);
1411 #endif
1412 return _bfd_save_vms_section (abfd, section, location, offset, count);
1413 }
1414
1415 /* Part 4.8, linker. */
1416
1417 /* Get the size of the section headers. */
1418
1419 static int
1420 vms_sizeof_headers (bfd * abfd ATTRIBUTE_UNUSED,
1421 struct bfd_link_info *info ATTRIBUTE_UNUSED)
1422 {
1423 #if VMS_DEBUG
1424 vms_debug (1, "vms_sizeof_headers (%p, %s)\n", abfd, (reloc)?"True":"False");
1425 #endif
1426 return 0;
1427 }
1428
1429 /* Provides default handling of relocation effort for back ends
1430 which can't be bothered to do it efficiently. */
1431
1432 static bfd_byte *
1433 vms_bfd_get_relocated_section_contents (bfd * abfd ATTRIBUTE_UNUSED,
1434 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1435 struct bfd_link_order *link_order ATTRIBUTE_UNUSED,
1436 bfd_byte *data ATTRIBUTE_UNUSED,
1437 bfd_boolean relocatable ATTRIBUTE_UNUSED,
1438 asymbol **symbols ATTRIBUTE_UNUSED)
1439 {
1440 #if VMS_DEBUG
1441 vms_debug (1, "vms_bfd_get_relocated_section_contents (%p, %p, %p, %p, %s, %p)\n",
1442 abfd, link_info, link_order, data, (relocatable)?"True":"False", symbols);
1443 #endif
1444 return NULL;
1445 }
1446
1447 /* ??? */
1448
1449 static bfd_boolean
1450 vms_bfd_relax_section (bfd * abfd ATTRIBUTE_UNUSED,
1451 asection *section ATTRIBUTE_UNUSED,
1452 struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
1453 bfd_boolean *again ATTRIBUTE_UNUSED)
1454 {
1455 #if VMS_DEBUG
1456 vms_debug (1, "vms_bfd_relax_section (%p, %s, %p, <ret>)\n",
1457 abfd, section->name, link_info);
1458 #endif
1459 return TRUE;
1460 }
1461
1462 static bfd_boolean
1463 vms_bfd_gc_sections (bfd * abfd ATTRIBUTE_UNUSED,
1464 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1465 {
1466 #if VMS_DEBUG
1467 vms_debug (1, "vms_bfd_gc_sections (%p, %p)\n", abfd, link_info);
1468 #endif
1469 return TRUE;
1470 }
1471
1472 static bfd_boolean
1473 vms_bfd_merge_sections (bfd * abfd ATTRIBUTE_UNUSED,
1474 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1475 {
1476 #if VMS_DEBUG
1477 vms_debug (1, "vms_bfd_merge_sections (%p, %p)\n", abfd, link_info);
1478 #endif
1479 return TRUE;
1480 }
1481
1482 /* Create a hash table for the linker. Different backends store
1483 different information in this table. */
1484
1485 static struct bfd_link_hash_table *
1486 vms_bfd_link_hash_table_create (bfd * abfd ATTRIBUTE_UNUSED)
1487 {
1488 #if VMS_DEBUG
1489 vms_debug (1, "vms_bfd_link_hash_table_create (%p)\n", abfd);
1490 #endif
1491 return NULL;
1492 }
1493
1494 /* Free a linker hash table. */
1495
1496 static void
1497 vms_bfd_link_hash_table_free (struct bfd_link_hash_table *hash ATTRIBUTE_UNUSED)
1498 {
1499 #if VMS_DEBUG
1500 vms_debug (1, "vms_bfd_link_hash_table_free (%p)\n", abfd);
1501 #endif
1502 }
1503
1504 /* Add symbols from this object file into the hash table. */
1505
1506 static bfd_boolean
1507 vms_bfd_link_add_symbols (bfd * abfd ATTRIBUTE_UNUSED,
1508 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1509 {
1510 #if VMS_DEBUG
1511 vms_debug (1, "vms_bfd_link_add_symbols (%p, %p)\n", abfd, link_info);
1512 #endif
1513 return FALSE;
1514 }
1515
1516 /* Do a link based on the link_order structures attached to each
1517 section of the BFD. */
1518
1519 static bfd_boolean
1520 vms_bfd_final_link (bfd * abfd ATTRIBUTE_UNUSED,
1521 struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
1522 {
1523 #if VMS_DEBUG
1524 vms_debug (1, "vms_bfd_final_link (%p, %p)\n", abfd, link_info);
1525 #endif
1526 return TRUE;
1527 }
1528
1529 /* Should this section be split up into smaller pieces during linking. */
1530
1531 static bfd_boolean
1532 vms_bfd_link_split_section (bfd * abfd ATTRIBUTE_UNUSED,
1533 asection *section ATTRIBUTE_UNUSED)
1534 {
1535 #if VMS_DEBUG
1536 vms_debug (1, "vms_bfd_link_split_section (%p, %s)\n", abfd, section->name);
1537 #endif
1538 return FALSE;
1539 }
1540
1541 /* Part 4.9, dynamic symbols and relocations. */
1542
1543 /* Get the amount of memory required to hold the dynamic symbols. */
1544
1545 static long
1546 vms_get_dynamic_symtab_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
1547 {
1548 #if VMS_DEBUG
1549 vms_debug (1, "vms_get_dynamic_symtab_upper_bound (%p)\n", abfd);
1550 #endif
1551 return 0;
1552 }
1553
1554 static bfd_boolean
1555 vms_bfd_print_private_bfd_data (bfd * abfd ATTRIBUTE_UNUSED,
1556 void *file ATTRIBUTE_UNUSED)
1557 {
1558 #if VMS_DEBUG
1559 vms_debug (1, "vms_bfd_print_private_bfd_data (%p)\n", abfd);
1560 #endif
1561 return FALSE;
1562 }
1563
1564 /* Read in the dynamic symbols. */
1565
1566 static long
1567 vms_canonicalize_dynamic_symtab (bfd * abfd ATTRIBUTE_UNUSED,
1568 asymbol **symbols ATTRIBUTE_UNUSED)
1569 {
1570 #if VMS_DEBUG
1571 vms_debug (1, "vms_canonicalize_dynamic_symtab (%p, <ret>)\n", abfd);
1572 #endif
1573 return 0L;
1574 }
1575
1576 /* Get the amount of memory required to hold the dynamic relocs. */
1577
1578 static long
1579 vms_get_dynamic_reloc_upper_bound (bfd * abfd ATTRIBUTE_UNUSED)
1580 {
1581 #if VMS_DEBUG
1582 vms_debug (1, "vms_get_dynamic_reloc_upper_bound (%p)\n", abfd);
1583 #endif
1584 return 0L;
1585 }
1586
1587 /* Read in the dynamic relocs. */
1588
1589 static long
1590 vms_canonicalize_dynamic_reloc (bfd * abfd ATTRIBUTE_UNUSED,
1591 arelent **arel ATTRIBUTE_UNUSED,
1592 asymbol **symbols ATTRIBUTE_UNUSED)
1593 {
1594 #if VMS_DEBUG
1595 vms_debug (1, "vms_canonicalize_dynamic_reloc (%p)\n", abfd);
1596 #endif
1597 return 0L;
1598 }
1599 \f
1600 const bfd_target vms_alpha_vec =
1601 {
1602 "vms-alpha", /* Name. */
1603 bfd_target_evax_flavour,
1604 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
1605 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
1606
1607 (HAS_RELOC | HAS_SYMS
1608 | WP_TEXT | D_PAGED), /* Object flags. */
1609 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
1610 | SEC_READONLY | SEC_CODE | SEC_DATA
1611 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
1612 0, /* Symbol_leading_char. */
1613 ' ', /* AR_pad_char. */
1614 15, /* AR_max_namelen. */
1615 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1616 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1617 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
1618 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1619 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1620 bfd_getl16, bfd_getl_signed_16, bfd_putl16,
1621
1622 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
1623 vms_archive_p, _bfd_dummy_target},
1624 {bfd_false, vms_mkobject, /* bfd_set_format. */
1625 _bfd_generic_mkarchive, bfd_false},
1626 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
1627 _bfd_write_archive_contents, bfd_false},
1628
1629 BFD_JUMP_TABLE_GENERIC (vms),
1630 BFD_JUMP_TABLE_COPY (vms),
1631 BFD_JUMP_TABLE_CORE (vms),
1632 BFD_JUMP_TABLE_ARCHIVE (vms),
1633 BFD_JUMP_TABLE_SYMBOLS (vms),
1634 BFD_JUMP_TABLE_RELOCS (vms),
1635 BFD_JUMP_TABLE_WRITE (vms),
1636 BFD_JUMP_TABLE_LINK (vms),
1637 BFD_JUMP_TABLE_DYNAMIC (vms),
1638
1639 NULL,
1640
1641 NULL
1642 };
1643
1644 const bfd_target vms_vax_vec =
1645 {
1646 "vms-vax", /* Name. */
1647 bfd_target_ovax_flavour,
1648 BFD_ENDIAN_LITTLE, /* Data byte order is little. */
1649 BFD_ENDIAN_LITTLE, /* Header byte order is little. */
1650
1651 (HAS_RELOC | HAS_SYMS /* Object flags. */
1652 | WP_TEXT | D_PAGED
1653 | HAS_LINENO | HAS_DEBUG | HAS_LOCALS),
1654
1655 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
1656 | SEC_READONLY | SEC_CODE | SEC_DATA
1657 | SEC_HAS_CONTENTS | SEC_IN_MEMORY), /* Sect flags. */
1658 0, /* Symbol_leading_char. */
1659 ' ', /* AR_pad_char. */
1660 15, /* AR_max_namelen. */
1661 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1662 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1663 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */
1664 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
1665 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
1666 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers. */
1667
1668 {_bfd_dummy_target, vms_object_p, /* bfd_check_format. */
1669 vms_archive_p, _bfd_dummy_target},
1670 {bfd_false, vms_mkobject, /* bfd_set_format. */
1671 _bfd_generic_mkarchive, bfd_false},
1672 {bfd_false, vms_write_object_contents, /* bfd_write_contents. */
1673 _bfd_write_archive_contents, bfd_false},
1674
1675 BFD_JUMP_TABLE_GENERIC (vms),
1676 BFD_JUMP_TABLE_COPY (vms),
1677 BFD_JUMP_TABLE_CORE (vms),
1678 BFD_JUMP_TABLE_ARCHIVE (vms),
1679 BFD_JUMP_TABLE_SYMBOLS (vms),
1680 BFD_JUMP_TABLE_RELOCS (vms),
1681 BFD_JUMP_TABLE_WRITE (vms),
1682 BFD_JUMP_TABLE_LINK (vms),
1683 BFD_JUMP_TABLE_DYNAMIC (vms),
1684
1685 NULL,
1686
1687 NULL
1688 };